In Python classes, @staticmethod, @classmethod, and regular instance methods differ in
how they receive and use their first argument and how they relate to the class and its instances.
1. Regular Instance Methods
First parameter:self (the instance itself)
Can access and modify instance attributes and other instance methods.
Called on an instance of the class.
class MyClass:
def instance_method(self):
print(f"Called instance_method of {self}")
obj = MyClass()
obj.instance_method() # Works, 'self' refers to 'obj'
2. @staticmethod
Does NOT take self or cls as the first argument.
Behaves like a regular function inside the class namespace.
Cannot access instance (self) or class (cls) data.
Called on the class or instance, but no reference to either is passed automatically.
class MyClass:
@staticmethod
def static_method():
print("Called static_method")
MyClass.static_method() # Works
obj = MyClass()
obj.static_method() # Also works
3. @classmethod
First parameter is cls (the class itself).
Can access and modify class state that applies across all instances.
Called on the class or instance, but receives the class as the first argument.
class MyClass:
class_var = 0
@classmethod
def class_method(cls):
print(f"Called class_method of {cls}")
print(f"Class variable: {cls.class_var}")
MyClass.class_method() # Works
obj = MyClass()
obj.class_method() # Also works, cls is MyClass
Summary Table
Method Type
First Argument
Can Access Instance Data?
Can Access Class Data?
How Called
Instance Method
self
Yes
Yes
obj.method()
Static Method
None
No
No
Class.method() or obj.method()
Class Method
cls
No
Yes
Class.method() or obj.method()
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
In Python classes,
@staticmethod,@classmethod, and regular instance methods differ in how they receive and use their first argument and how they relate to the class and its instances.1. Regular Instance Methods
self(the instance itself)2. @staticmethod
selforclsas the first argument.self) or class (cls) data.3. @classmethod
cls(the class itself).Summary Table
selfobj.method()Class.method()orobj.method()clsClass.method()orobj.method()