I have a class as follows:
class MyClass(object):
int = None
def __init__(self, *args, **kwargs):
for k, v in kwargs.iteritems():
You can call instance method with classmethod when treating it like instance method and add class as instance. IMO it is really bad practice, but it solves your problem.
@classmethod
def new(cls):
params = cls.get_params(cls)
return cls(**params)
No, you can't and shouldn't call an instance method from a class without an instance. This would be very bad. You can, however call, a class method from and instance method. Options are
get_param
a class method and fix references to it__init__
call get_param
, since it is a instance methodAlso you may be interested in an AttrDict since that looks like what you are trying to do.