Asked By – Pablo
When I have regular methods for calling another method in a class, I have to do this
class test: def __init__(self): pass def dosomething(self): print "do something" self.dosomethingelse() def dosomethingelse(self): print "do something else"
but when I have static methods I can’t write
because there is no instance. What do I have to do in Python for calling an static method from another static method of the same class?
Now we will see solution for issue: Static methods – How to call a method from another method?
class.method should work.
class SomeClass: @classmethod def some_class_method(cls): pass @staticmethod def some_static_method(): pass SomeClass.some_class_method() SomeClass.some_static_method()
This question is answered By – jldupont
This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0