Python 101 : Class methods


If a method has a @classmethod decorator, then it is a class method.

class method has as its first argument "cls" which refers to the class itself.
Changes made to the class and its attributes has an impact on all its instances. 

Below, we define a class method for class "c" that increments the value of "count" by one:

Comments

Leave as a comment:

Archive