In this tutorial, you’ll learn the differences between class methods, static methods, and instance methods step by step, and when to use each one.
In object-oriented programming, when we design a class, we use the following three types of methods:
- An instance method performs a set of actions on the data stored in the object’s instance variables. If a method uses instance variables, it’s an instance method.
- A class method is bound to the class itself, not to a specific object. It works at the class level, and all instances of the class share it.
- A static method is a general utility method that performs a task in isolation. It has no access to instance or class variables.

Table of contents
Quick Comparison
| Instance Method | Class Method | Static Method | |
|---|---|---|---|
| Decorator | None (default) | @classmethod | @staticmethod |
| First parameter | self (the object) | cls (the class) | None |
| Access instance variables | Yes | No | No |
| Access class variables | Yes | Yes | No (only by hard-coding the class name) |
| Modify object state | Yes | No | No |
| Modify class state | Yes (through self.__class__) | Yes | No |
| Called using | An object | The class or an object | The class or an object |
| Typical use | Behavior of an individual object | Factory methods, class-wide settings | Utility and helper functions |
Difference #1: Primary Use
- A class method is used to access or modify the class state. It can change the value of a class variable, and the change applies to all objects of the class.
- An instance method acts on an object’s attributes. It can modify the object’s state by changing the values of its instance variables.
- Static methods have a narrower use, because they can’t access an object’s attributes (instance variables) or the class’s attributes (class variables). They’re useful for helpers, such as converting a value from one type or unit to another.
Class methods are often used as factory methods. A factory method creates and returns an object of the class for a specific use case, for example when the input data needs some pre-processing before the object can be created.
Read our separate tutorials on
Difference #2: Method Definition
Let’s learn how to define an instance method, a class method, and a static method in a class. Each one is defined in a slightly different way.
- All three are defined inside a class, much like a regular function.
- Every method in a class is an instance method by default. To create a class method or a static method, we must tell Python explicitly.
- Use the
@classmethoddecorator (or theclassmethod()function) to define a class method. - Use the
@staticmethoddecorator (or thestaticmethod()function) to define a static method.
Example:
- Use
selfas the first parameter of an instance method. Theselfparameter refers to the current object. - Use
clsas the first parameter of a class method.clsrefers to the class. - A static method takes neither the instance nor the class as a parameter, so it has no access to instance variables or class variables.
As you can see in the example, the instance method show() takes self, the class method change_school() takes cls, and the static method find_notes() takes only its own argument.
Difference #3: Method Call
- Class methods and static methods can be called using the class name or an object of the class.
- An instance method is normally called using an object of the class. You can also call it through the class, but then you must pass the object yourself, for example
Student.show(jessa).
Example:
Output:
Jessa 12 ABC School School name changed to XYZ School School name changed to PQR School ['chapter 1', 'chapter 2', 'chapter 3'] ['chapter 1', 'chapter 2', 'chapter 3'] Jessa 12 PQR School
Difference #4: Attribute Access
Both a class and its objects have attributes. Class attributes are the class variables, and object attributes are the instance variables.
- An instance method can access both class-level and object attributes. Therefore, it can modify the object state.
- A class method can access only class-level attributes. Therefore, it can modify the class state.
- A static method has no access to class attributes or instance attributes. Therefore, it cannot modify the class or object state.
Example:
Output:
Student: Jessa 12 School: ABC School Previous School name: ABC School School name changed to XYZ School
Difference #5: Class Bound and Instance Bound
- An instance method is bound to the object. When you access it through an object, Python creates a bound method that automatically passes that object as
self. - A class method is bound to the class. Python automatically passes the class as
cls, even when you call it through an object. - A static method isn’t bound to anything. It’s a plain function stored in the class, so Python passes nothing automatically.
Example:
Output:
<bound method Student.show of <__main__.Student object at 0x7f...>> <bound method Student.change_school of <class '__main__.Student'>> <function Student.find_notes at 0x7f...>
As you can see in the output, show() is bound to the Student object, change_school() is bound to the Student class, and find_notes() is a plain function. (The memory addresses will differ on your machine.)
Do you know:
Python does not create a separate copy of each instance method for every object. All methods, instance, class, and static, are stored only once, in the class. When you access an instance method through an object, Python creates a lightweight bound method object on the fly. That’s why two accesses are not the same object, even though they share the same underlying function.
Example:
Which One Should You Use?
Ask what data the method needs:
- Needs the object’s data (instance variables)? Use an instance method. This is the most common case.
- Needs the class (class variables, or creating new objects)? Use a class method.
- Needs neither, but logically belongs to the class? Use a static method.
The following example uses all three in one class.
Output:
Pizza with mozzarella, tomato False True
