EC Lecture Notes - Lecture 2: Class Variable, Function Overloading, Init
Document Summary
The @classmethod decorator, is a built-in function decorator that is an expression that gets evaluated after your function is defined. The result of that evaluation shadows your function definition. A class method receives the class as implicit first argument, just like an instance method receives the instance. @classmethod def fun(cls, arg1, arg2, ): fun: function that needs to be converted into a class method returns: a class method for function. A class method is a method which is bound to the class and not the object of the class. They have the access to the state of the class as it takes a class parameter that points to the class and not the object instance. It can modify a class state that would apply across all the instances of the class. For example it can modify a class variable that will be applicable to all the instances. A static method does not receive an implicit first argument.