I'm working on an already established Python 2.7 Project, there needs to be some modification and I'm still relatively new to Python, here's what I did:
I have 2 functions in the same class, one is @staticmethod and other is a @classmethod. I need to call @classmethod from inside @staticmethod like -
class ABC(object):
@classmethod
def classm(self, name):
...
@staticmethod
def staticm(freq):
...
...
classm("sample")
The above piece of code doesn't work, so I converted the staticmethod to classmethod and then it worked fine (using 'self' in correct places)
Can someone please explain if we can call classmethod from staticmethod (most probably it seems that I don't know the syntax), if not, is there a better workaround without converting?
ClassName.class_method(...)or use the class object which is passed into class methods.@staticmethoddecorator is not the right choice. You have class method then.