DEV Community

tp1050
tp1050

Posted on

dynamic name setting for classes

When you need to create classes on the go , this is the easiest way

def create_class(cls_name):
def init(self,*args, **kwargs):
super(type(self),self).init(*args, **kwargs)
pass

return type(cls_name.upper(), (Parrent_Class), {'__init__': __init__,'__some_hidden_stuff__' : cls_name.lower(),'none_hidden_stuff':'some value})
Enter fullscreen mode Exit fullscreen mode

Top comments (0)