What are Python's class and static methods?
Answer
Python classes have three types of methods. Instance methods (default): receive self (the instance) as first argument — can access and modify instance and class state. Class methods decorated with @classmethod: receive cls (the class) as first argument — can access and modify class state but not instance state. Used as alternative constructors: @classmethod def from_string(cls, s): return cls(*s.split(",")). Static methods decorated with @staticmethod: receive no implicit first argument — they are just regular functions namespaced inside the class. They cannot access or modify class or instance state. Use for utility functions related to the class but not dependent on it. Example: @staticmethod def validate(value): return isinstance(value, int) and value > 0.