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?

12th Oct 2016, 12:51 PM
Waqif Alam
Waqif Alam - avatar
3 Respuestas
+ 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.
15th Oct 2016, 12:37 AM
Róbert Csomor
Róbert Csomor - avatar
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.
12th Oct 2016, 6:31 PM
Pramod Lagare
Pramod Lagare - avatar
0
No I mean why use a classmethod instead of a normal method within a class?
12th Oct 2016, 6:33 PM
Waqif Alam
Waqif Alam - avatar