What is the difference between staticmethod and classmethod?
Reveal the answer and explore the explanation.
07MediumHigh priorityWhat is the difference between staticmethod and classmethod?
Answer
MediumHigh priority
What is the difference between staticmethod and classmethod?
Answer
A static method receives no implicit instance or class argument; a class method receives the class as its first argument.
Practical example
Use a classmethod as an alternative constructor and a staticmethod for a stateless helper.
Reference: Further reading ↗