Python Classes
__init__, self, instance vs class variables, staticmethod vs classmethod
35 min · interactive lesson with runnable code and 5 graded exercises.
What you'll be able to do
- Explain what __init__ and self do
- Tell instance variables from class variables — and avoid shared mutable state
- Choose between @staticmethod and @classmethod
- Write alternative constructors that work with subclasses
The full lesson is free with an account.