
Christopher S. answered 05/10/19
Christo: Online programming and Computer Literacy tutor
So when you are making a class, you might want more than one way to make a new instance of the class Or perhaps you want slightly different ways of creating an object based on how many resources you have available to you. These would be classic uses of @classmethod.
In the following example, a class method is used as a way to initialize a Person object based on their Year of Birth rather than a simple age number.
Notice that this example (sourced from https://www.geeksforgeeks.org/class-method-vs-static-method-python/) includes also a @staticmethod.
A static method is for functions that you can call without needing a particular instance of the object. so if I rewrite this a little bit to get rid of the person1 and person2 objects, we can still call the isAdult function.
Running this code will print out "True" as all that is happening is that, because the isAdult method does not rely on the internal values of the Person class, it needs no particular instance of Person to run and give you the fact that a 22 year old is an Adult.