+ 3
When should one use a classmethod instead of a static method?
2 Respostas
+ 6
A staticmethod is a method that knows nothing about the class or instance it was called on. It just gets the arguments that were passed, no implicit first argument. It is basically useless in Python - you can just use a module function instead of a staticmethod.
A classmethod, on the other hand, is a method that gets passed the class it was called on, or the class of the instance it was called on, as first argument.
0
Actually, you don't answer the question and a static method is not useless, it just doesn't use any information in the instance dictionary.
When you work with clouds, for instance, you have to convert pressures to different units. How do you do that easily with module functions ?