2 Antworten
+ 2
@classmethod is a shortcut for this older way of writing:
f = classmethod(some_function)
The difference is just that instead of an instance, the class is passed when you call it.
+ 1
The way itself is typical for many languages. In C# e.g. it is called static. They are used for things which do not have to be represented in objects. Think about using methods of Math. It are calculations, which do not have a state outside the method. In difference to that a calculator presented to a user may have a state, the result of a calculation with which you might want to proceed calculating. Of course you could hold that value once only, but latest when you can show two calculators at the same time you need to organize them, for which objects are designed.