PYnative

Practice Coding

  • Python â–¼
    • Python Tutorials
    • Python Basics
    • Python Interview Q&As
  • Coding Exercises â–¼
    • Python Exercises
    • C++ Exercises
    • C Programming Exercises
    • Java Exercises
    • C# Exercises
  • MCQsâ–¼
    • Python MCQ Quizzes
    • Java MCQ Quizzes
    • C++ MCQ Quizzes
  • Compilersâ–¼
    • Online Python Compiler
    • Online C Compiler
    • Online C++ Compiler
    • Online Java Compiler
    • Online C# Compiler
Home » Python » Python Object-Oriented Programming (OOP) » Python Class Method vs. Static Method vs. Instance Method

Python Class Method vs. Static Method vs. Instance Method

Updated on: December 4, 2026 | 7 Comments

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.
Python class method vs static method vs instance method
class method vs static method vs instance method

Table of contents

  • Quick Comparison
  • Difference #1: Primary Use
  • Difference #2: Method Definition
  • Difference #3: Method Call
  • Difference #4: Attribute Access
  • Difference #5: Class Bound and Instance Bound
  • Which One Should You Use?

Quick Comparison

Instance MethodClass MethodStatic Method
DecoratorNone (default)@classmethod@staticmethod
First parameterself (the object)cls (the class)None
Access instance variablesYesNoNo
Access class variablesYesYesNo (only by hard-coding the class name)
Modify object stateYesNoNo
Modify class stateYes (through self.__class__)YesNo
Called usingAn objectThe class or an objectThe class or an object
Typical useBehavior of an individual objectFactory methods, class-wide settingsUtility and helper functions
Instance method vs class method vs static method

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

  • Instance methods in Python
  • Class method in Python
  • Static method in Python

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 @classmethod decorator (or the classmethod() function) to define a class method.
  • Use the @staticmethod decorator (or the staticmethod() function) to define a static method.

Example:

  • Use self as the first parameter of an instance method. The self parameter refers to the current object.
  • Use cls as the first parameter of a class method. cls refers 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.
class Student:
    # class variable
    school_name = 'ABC School'

    # constructor
    def __init__(self, name, age):
        # instance variables
        self.name = name
        self.age = age

    # instance method
    def show(self):
        print(self.name, self.age, Student.school_name)

    @classmethod
    def change_school(cls, name):
        cls.school_name = name
        print('School name changed to', cls.school_name)

    @staticmethod
    def find_notes(subject_name):
        return ['chapter 1', 'chapter 2', 'chapter 3']Code language: Python (python)

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:

class Student:
    # class variable
    school_name = 'ABC School'

    def __init__(self, name, age):
        # instance variables
        self.name = name
        self.age = age

    # instance method
    def show(self):
        print(self.name, self.age, Student.school_name)

    @classmethod
    def change_school(cls, name):
        cls.school_name = name
        print('School name changed to', cls.school_name)

    @staticmethod
    def find_notes(subject_name):
        return ['chapter 1', 'chapter 2', 'chapter 3']

# create object
jessa = Student('Jessa', 12)
# call instance method
jessa.show()

# call class method using the class
Student.change_school('XYZ School')
# call class method using the object
jessa.change_school('PQR School')

# call static method using the class
print(Student.find_notes('Math'))
# call static method using the object
print(jessa.find_notes('Math'))

# instance method can also be called through the class
Student.show(jessa)Code language: Python (python)

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:

class Student:
    # class variables
    school_name = 'ABC School'

    def __init__(self, name, age):
        self.name = name
        self.age = age

    # instance method
    def show(self):
        # access instance variables
        print('Student:', self.name, self.age)
        # access class variables
        print('School:', self.school_name)

    @classmethod
    def change_school(cls, name):
        # access class variable
        print('Previous School name:', cls.school_name)
        cls.school_name = name
        print('School name changed to', cls.school_name)

    @staticmethod
    def find_notes(subject_name):
        # can't access instance or class attributes
        return ['chapter 1', 'chapter 2', 'chapter 3']

# create object
jessa = Student('Jessa', 12)
# call instance method
jessa.show()

# call class method
Student.change_school('XYZ School')Code language: Python (python)

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:

class Student:
    def __init__(self, roll_no):
        self.roll_no = roll_no

    # instance method
    def show(self):
        print('In Instance method')

    @classmethod
    def change_school(cls, name):
        print('In class method')

    @staticmethod
    def find_notes(subject_name):
        print('In Static method')

jessa = Student(12)

# instance method bound to object
print(jessa.show)
# class method bound to class
print(jessa.change_school)
# static method is not bound
print(jessa.find_notes)
Code language: Python (python)

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:

# create two objects
jessa = Student(12)
kelly = Student(25)

# False: a new bound method is created on each access
print(jessa.show is kelly.show)

# True: both use the same function stored in the class
print(jessa.show.__func__ is kelly.show.__func__)

# True: static methods are returned as the same plain function
print(jessa.find_notes is kelly.find_notes)Code language: Python (python)

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.

class Pizza:
    def __init__(self, toppings):
        self.toppings = toppings

    # instance method: works with this pizza's data
    def describe(self):
        print('Pizza with', ', '.join(self.toppings))

    # class method: alternative constructor
    @classmethod
    def margherita(cls):
        return cls(['mozzarella', 'tomato'])

    # static method: helper that needs no object or class data
    @staticmethod
    def is_vegetarian(topping):
        return topping not in ('ham', 'pepperoni', 'chicken')

p = Pizza.margherita()
p.describe()
print(Pizza.is_vegetarian('ham'))
print(all(Pizza.is_vegetarian(t) for t in p.toppings))Code language: Python (python)

Output:

Pizza with mozzarella, tomato
False
True

Filed Under: Python, Python Object-Oriented Programming (OOP)

Did you find this page helpful? Let others know about it. Sharing helps me continue to create free Python resources.

TweetF  sharein  shareP  Pin

About Vishal

I’m Vishal Hule, the Founder of PYnative.com. As a Python developer, I enjoy assisting students, developers, and learners. Follow me on Twitter.

Related Tutorial Topics:

Python Python Object-Oriented Programming (OOP)

All Coding Exercises:

C Exercises
C++ Exercises
Python Exercises
Java Exercises
C# Exercises

Python Exercises and Quizzes

Free coding exercises and quizzes cover Python basics, data structure, data analytics, and more.

  • 15+ Topic-specific Exercises and Quizzes
  • Each Exercise contains 25+ questions
  • Each Quiz contains 25 MCQ
Exercises
Quizzes
In: Python Python Object-Oriented Programming (OOP)
TweetF  sharein  shareP  Pin

  Python OOP

  • Python OOP
  • Classes and Objects in Python
  • Constructors in Python
  • Python Destructors
  • Encapsulation in Python
  • Polymorphism in Python
  • Inheritance in Python
  • Python Instance Variables
  • Python Instance Methods
  • Python Class Variables
  • Python Class Method
  • Python Static Method
  • Python Class Method vs. Static Method vs. Instance Method
  • Python OOP exercise

 Explore Python

  • Python Tutorials
  • Python Exercises
  • Python Quizzes
  • Python Interview Q&A
  • Python Programs

All Python Topics

Python Basics Python Exercises Python Quizzes Python Interview Python File Handling Python OOP Python Date and Time Python Random Python Regex Python Pandas Python Databases Python MySQL Python PostgreSQL Python SQLite Python JSON

About PYnative

PYnative.com is a platform built to help developers learn by doing. Solve coding exercises, take MCQs, and run code directly in built-in online compilers.

Follow Us

To get New Python Tutorials, Exercises, and Quizzes

  • Twitter
  • Facebook
  • Sitemap

Explore Python

  • Learn Python
  • Python Basics
  • Python Databases
  • Python Exercises
  • Python Quizzes
  • Online Python Code Editor
  • Python Tricks

Coding Exercises

  • C Exercises
  • C++ Exercises
  • Python Exercises
  • Java Exercises
  • C# Exercises

MCQ Quizzes

  • Python MCQs
  • Java MCQs
  • C++ MCQs

Legal Stuff

  • About Us
  • Contact Us

We use cookies to improve your experience. While using PYnative, you agree to have read and accepted our:

  • Terms Of Use
  • Privacy Policy
  • Cookie Policy

Copyright © 2018–2026 pynative.com