class method vs static method in Python ?
class method vs static method
764
25-Jun-2018
Prakash nidhi Verma
26-Jun-2018Class Methods:
It is a built-in function decorator that's evaluate the function. The result of that evaluation shadows decide our function definition. A class method receives the class as most first argument like as an instance method for receiving the instance.
Syntax:
fun: function which is needs to be converted into a class method
returns: a class method for define function. A class method is a method which is bound to the class but not for the object of the class.
Static Method : It's does not receive an most first argument.
Syntax:
returns: a static method for function fun. static method is like a method which is bound to a class but its not a object of the class.
Difference between Class and Method :
- A class method takes cls as first parameter but a static method needs not a any parameters.
- A class method can access or modify class state while a static method can’t access or modify it.