0
Why use classmethods and staticmethods?
what can a method not do that a classmethod or a staticmethod can? What can a classmethod do that a staticmethod can't?
3 odpowiedzi
+ 1
It is based on the problem you want to solve. Because static methods are not related to classes you can create functions for general usage in a helper static class.
helper.createFunForMe()
But if a method is technically releated to objects, like calculate data in an object it needed to be linked to the object by defining it in the non-static class.
0
To acess class method you hv to create object of that class. You can acess static method by direct class name.
In static method you use only static member.
0
No I mean why use a classmethod instead of a normal method within a class?