QUESTION 7 OF 10

What is the difference between staticmethod and classmethod?

Reveal the answer and explore the explanation.

07
MediumHigh priority

What is the difference between staticmethod and classmethod?

Answer
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 ↗

Last 30 min revisionHigh-yield interview Q&As