What does `@staticmethod` differ from `@classmethod` in Python?

Python Professional Hard

Python Professional — Hard

What does `@staticmethod` differ from `@classmethod` in Python?

Key points

  • Class methods are bound to the class itself, hence the `cls` argument
  • Static methods do not have access to the class or instance
  • Class methods can modify the class state, while static methods cannot

Ready to go further?

Related questions