Maybe a bit of example code will help: Notice the difference in the call signatures of foo, class_foo and static_foo:

class A(object):
    def foo(self, x):
        print(f"executing foo({self}, {x})")

    @classmethod
    def class_foo(cls, x):
        print(f"executing class_foo({cls}, {x})")

    @staticmethod
    def static_foo(x):
        print(f"executing static_foo({x})")

a = A()

Below is the usual way an object instance calls a method. The object instance, a, is implicitly passed as the first argument.

a.foo(1)
# executing foo(<__main__.A object at 0xb7dbef0c>, 1)

With classmethods, the class of the object instance is implicitly passed as the first argument instead of self.

a.class_foo(1)
# executing class_foo(<class '__main__.A'>, 1)

You can also call class_foo using the class. In fact, if you define something to be a classmethod, it is probably because you intend to call it from the class rather than from a class instance. A.foo(1) would have raised a TypeError, but A.class_foo(1) works just fine:

A.class_foo(1)
# executing class_foo(<class '__main__.A'>, 1)

One use people have found for class methods is to create inheritable alternative constructors.


With staticmethods, neither self (the object instance) nor cls (the class) is implicitly passed as the first argument. They behave like plain functions except that you can call them from an instance or the class:

a.static_foo(1)
# executing static_foo(1)

A.static_foo('hi')
# executing static_foo(hi)

Staticmethods are used to group functions which have some logical connection with a class to the class.


foo is just a function, but when you call a.foo you don't just get the function, you get a "partially applied" version of the function with the object instance a bound as the first argument to the function. foo expects 2 arguments, while a.foo only expects 1 argument.

a is bound to foo. That is what is meant by the term "bound" below:

print(a.foo)
# <bound method A.foo of <__main__.A object at 0xb7d52f0c>>

With a.class_foo, a is not bound to class_foo, rather the class A is bound to class_foo.

print(a.class_foo)
# <bound method type.class_foo of <class '__main__.A'>>

Here, with a staticmethod, even though it is a method, a.static_foo just returns a good 'ole function with no arguments bound. static_foo expects 1 argument, and a.static_foo expects 1 argument too.

print(a.static_foo)
# <function static_foo at 0xb7d479cc>

And of course the same thing happens when you call static_foo with the class A instead.

print(A.static_foo)
# <function static_foo at 0xb7d479cc>
Answer from unutbu on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › class-method-vs-static-method-python
Class method vs Static method in Python - GeeksforGeeks
2 days ago - A static method is a method that does not receive self or cls automatically. It behaves like a normal function but is placed inside a class because it logically belongs there. It cannot access or modify class or instance data directly.
🌐
Medium
medium.com › @ryan_forrester_ › class-methods-vs-static-methods-in-python-a-clear-guide-47fcfd385e27
Class Methods vs Static Methods in Python: A Clear Guide | by ryan | Medium
November 4, 2024 - Key differences: 1. Class methods receive the class as the first argument (`cls`) 2. Static methods don’t receive any automatic arguments 3. Class methods can access and modify class state 4. Static methods can’t access class or instance ...
Discussions

@staticmethod vs @classmethod vs functions outside of class in Python - Software Engineering Stack Exchange
Example.static_method_example is ... or cls.static_method_example in a class method. ... @matsuo_basho By accessing a normal (instance) method through the class object you happen to get an unbound method that you could use as an ordinary function. But this is a pretty confusing design because you're using instance methods for something other than instance methods. Your approach might look easier to you, but it's far more confusing for everyone else. The normal Python way to implement ... More on softwareengineering.stackexchange.com
🌐 softwareengineering.stackexchange.com
August 22, 2021
CLASS & STATIC METHODS
Classes for Beginners A lot of beginners struggle to get their heads around classes, but they are pretty much fundamental to object orientated programming. I usually describe them as the programming equal of moulds used in factories as a template for making lots of things that are identical. Imagine pouring molten iron into a mould to make a simple iron pot. You might produce a set of instructions to be sold with the pots that tell the owner how to cook using the pot, how to care for it, etc. The same instructions apply to every pot BUT what owners actually do is entirely up to them. Some might make soup, another person a stew, etc. In Python, a class defines the basics of a possible object and some methods that come with it. (Methods are like functions, but apply to things made using the class.) When we want create a Python object using a class, we call it 'creating an instance of a class'. If you have a class called Room, you would create instances like this: lounge = Room() kitchen = Room() hall = Room() As you typically want to store the main dimensions (height, length, width) of a room, whatever it is used for, it makes sense to define that when the instance is created. You would therefore have a method called __init__ that accepts height, length, width and when you create an instance of Room you would provide that information: lounge = Room(1300, 4000, 2000) The __init__ method is called automatically when you create an instance. It is short for initialise (intialize). You can reference the information using lounge.height and so on. These are attributes of the lounge instance. I provided the measurements in mm but you could include a method (function inside a class) that converts between mm and ft. Thus, I could say something like lounge.height_in_ft(). Methods in classes are usually defined with a first parameter of self: def __init__(self, height, length, width): # code for __init__ def height_in_ft(self): # code to return height The self is a shorthand way of referring to an instance. When you use lounge.height_in_ft() the method knows that any reference to self means the lounge instance, so self.height means lounge.height but you don't have to write the code for each individual instance. Thus kitchen.height_in_ft() and bathroom.height_in_ft() use the same method, but you don't have to pass the height of the instance as the method can reference it using self.height EXAMPLE Room class The code shown as the end of this post will generate the following output: Lounge 1300 4000 4000 Snug 1300 2500 2500 Lounge length in feet: 4.26509187 Snug wall area: 11700000 in sq.mm., 125.94 in sq.ft. Note that a method definition that is preceded by the command, @staticmethod (a decorator) is really just a function that does not include the self reference to the calling instance. It is included in a class definition for convenience and can be called by reference to the class or the instance: Room.mm_to_ft(mm) lounge.mm_to_ft(mm) Here's the code for the full programme: class Room(): def __init__(self, name, height, length, width): self.name = name self.height = height self.length = length self.width = width @staticmethod def mm_to_ft(mm): return mm * 0.0032808399 @staticmethod def sqmm_to_sqft(sqmm): return sqmm * 1.07639e-5 def height_in_ft(self): return Room.mm_to_ft(self.height) def width_in_ft(self): return Room.mm_to_ft(self.width) def length_in_ft(self): return Room.mm_to_ft(self.length) def wall_area(self): return self.length * 2 * self.height + self.width * 2 * self.height lounge = Room('Lounge', 1300, 4000, 2000) snug = Room('Snug', 1300, 2500, 2000) print(lounge.name, lounge.height, lounge.length, lounge.length) print(snug.name, snug.height, snug.length, snug.length) print(lounge.name, 'length in feet:', lounge.height_in_ft()) print(f'{snug.name} wall area: {snug.wall_area()} in sq.mm., ' + \ f'{snug.sqmm_to_sqft(snug.wall_area()):.2f} in sq.ft.') Another useful decorator is @property, which allows you to refer to a method as if it is an attribute. Not used in the example, but if I put that before the height_in_ft methods you could say, for example, lounge.height_in_ft instead of lounge.height_in_ft(). One can write classes that are based on other classes. These child classes inherit all of the characteristics of the parent (or super) class but any attribute or method can be overridden to use alternatives that apply only to the child (and its children). Such child classes might have additional methods, alternative __init__ methods, different default output when referenced in a print statement, and so on. The example code code does not demonstrate this feature. More on reddit.com
🌐 r/learnpython
12
2
December 30, 2021
What is difference between class method and static method? (Please provide some good examples also). Thank you.
Static method doesn't take the class used to call that method as an argument/doesn't have such parameter More on reddit.com
🌐 r/learnpython
6
0
June 30, 2022
Why @classmethod and @staticmethod , why not use instance only ???
Class methods are great for writing alternate constructors (Say, parsing a particular data format). Static methods can be used for class-specific utils that don't operate on a class instance. More on reddit.com
🌐 r/learnpython
4
2
February 22, 2021
Top answer
1 of 16
4020

Maybe a bit of example code will help: Notice the difference in the call signatures of foo, class_foo and static_foo:

class A(object):
    def foo(self, x):
        print(f"executing foo({self}, {x})")

    @classmethod
    def class_foo(cls, x):
        print(f"executing class_foo({cls}, {x})")

    @staticmethod
    def static_foo(x):
        print(f"executing static_foo({x})")

a = A()

Below is the usual way an object instance calls a method. The object instance, a, is implicitly passed as the first argument.

a.foo(1)
# executing foo(<__main__.A object at 0xb7dbef0c>, 1)

With classmethods, the class of the object instance is implicitly passed as the first argument instead of self.

a.class_foo(1)
# executing class_foo(<class '__main__.A'>, 1)

You can also call class_foo using the class. In fact, if you define something to be a classmethod, it is probably because you intend to call it from the class rather than from a class instance. A.foo(1) would have raised a TypeError, but A.class_foo(1) works just fine:

A.class_foo(1)
# executing class_foo(<class '__main__.A'>, 1)

One use people have found for class methods is to create inheritable alternative constructors.


With staticmethods, neither self (the object instance) nor cls (the class) is implicitly passed as the first argument. They behave like plain functions except that you can call them from an instance or the class:

a.static_foo(1)
# executing static_foo(1)

A.static_foo('hi')
# executing static_foo(hi)

Staticmethods are used to group functions which have some logical connection with a class to the class.


foo is just a function, but when you call a.foo you don't just get the function, you get a "partially applied" version of the function with the object instance a bound as the first argument to the function. foo expects 2 arguments, while a.foo only expects 1 argument.

a is bound to foo. That is what is meant by the term "bound" below:

print(a.foo)
# <bound method A.foo of <__main__.A object at 0xb7d52f0c>>

With a.class_foo, a is not bound to class_foo, rather the class A is bound to class_foo.

print(a.class_foo)
# <bound method type.class_foo of <class '__main__.A'>>

Here, with a staticmethod, even though it is a method, a.static_foo just returns a good 'ole function with no arguments bound. static_foo expects 1 argument, and a.static_foo expects 1 argument too.

print(a.static_foo)
# <function static_foo at 0xb7d479cc>

And of course the same thing happens when you call static_foo with the class A instead.

print(A.static_foo)
# <function static_foo at 0xb7d479cc>
2 of 16
990

A staticmethod is a method that knows nothing about the class or instance it was called on. It just gets the arguments that were passed, no implicit first argument.

A classmethod, on the other hand, is a method that gets passed the class it was called on, or the class of the instance it was called on, as first argument. This is useful when you want the method to be a factory for the class: since it gets the actual class it was called on as first argument, you can always instantiate the right class, even when subclasses are involved. Observe for instance how dict.fromkeys(), a classmethod, returns an instance of the subclass when called on a subclass:

>>> class DictSubclass(dict):
...     def __repr__(self):
...         return "DictSubclass"
... 
>>> dict.fromkeys("abc")
{'a': None, 'c': None, 'b': None}
>>> DictSubclass.fromkeys("abc")
DictSubclass
>>> 
🌐
Real Python
realpython.com › instance-class-and-static-methods-demystified
Python's Instance, Class, and Static Methods Demystified – Real Python
March 17, 2025 - To get warmed up, you’ll write a small Python file called demo.py with a bare-bones Python class that contains stripped-down examples of all three method types: ... class DemoClass: def instance_method(self): return ("instance method called", self) @classmethod def class_method(cls): return ("class method called", cls) @staticmethod def static_method() return ("static method called",)
Top answer
1 of 2
3

If your method calls a static method on the class, then it does require information on the class. You have a class method, not a static method. By declaring it @classmethod (and adding the cls parameter), you not only properly inform the reader, you allow polymorphism. An inheritor can reimplement the called static method and change behavior.

2 of 2
2

Python's static methods are intended for methods that are part of a class, and can be called as either a class method or an instance method: both Class.the_method() and self.the_method() would work. When the static method is called, it is not given an implicit first argument:

class Example:
  def instance_method_example(self, arguments):
    ...

  @classmethod
  def class_method_example(cls, arguments):
    ...

  @staticmethod
  def static_method_example(arguments):
    ...

If you merely want to create a helper function that is used within your class, do not use @staticmethod. Define a free function outside of the class. For example:

class Example:
  def some_method(self, argument):
    return _helper(argument, self.x)

def _helper(a, b):
  ...

The background of static methods in Python is the following: when you access an attribute of an object x.attribute or getattr(x, 'attribute'), then this name is looked up in the instance dict or the class dict. If an object is found in the class dict, it is checked whether that object is a “descriptor”: an object that describes how this attribute behaves, not an object that would be directly returned. Descriptors have dunder-methods like __get__, __set__, and __del__ that are invoked depending on whether the descriptor is accessed, assigned to, or deleted with the del operator.

Functions – the things you declare with def – are descriptors. By default, the __get__ descriptor binds the function to the instance argument (typically called self) and returns the bound function, so that it can be invoked as a method. But the various decorators change this behaviour:

  • a @classmethod def binds to the class object, not the instance
  • a @staticmethod def does not bind to any object and just returns the underlying function directly
  • a @property invokes the underlying function to retrieve a value

These differences are (partially) visible when looking at the repr() of the bound methods. With the first Example class:

  • instance_method_example
    • with class: Example.instance_method_example
      is <function Example.instance_method_example at 0x7f1dfdd6fd30>,
      the unbound function
    • with instance: <function Example.instance_method_example at 0x7f1dfdd6fd30>
      is <bound method Example.instance_method_example of <__main__.Example object at 0x7f1dfdddcb80>>,
      a method bound to the instance
  • class_method_example
    • with class: Example.class_method_example
      is <bound method Example.class_method_example of <class '__main__.Example'>>,
      a method bound to the class
    • with instance: Example().class_method_example
      is <bound method Example.class_method_example of <class '__main__.Example'>>,
      also a method bound to the class
  • static_method_example
    • with class: Example.static_method_example
      is <function Example.static_method_example at 0x7f1dfdd6fe50>,
      the unbound function
    • with instance: Example().static_method_example
      is <function Example.static_method_example at 0x7f1dfdd6fe50>,
      also the unbound function

As a table:

invoked on… no decorator @classmethod @staticmethod
… instance bound to instance bound to class unbound
… class unbound bound to class unbound
🌐
Reddit
reddit.com › r/learnpython › class & static methods
r/learnpython on Reddit: CLASS & STATIC METHODS
December 30, 2021 -

Hello everyone,

I was studying OOP and the concept of instances, class methods and static methods still confuses me.

I have watched tons of YouTube already but I can't find a person who explains it as dumb as possible because that is how I understand things.

Please if there is anyone who can recommend to me a video or explain it to me in the simplest way possible with examples, I will be glad :)

Note: I want the simplest form of explanation about the matter.

Top answer
1 of 5
3
Classes for Beginners A lot of beginners struggle to get their heads around classes, but they are pretty much fundamental to object orientated programming. I usually describe them as the programming equal of moulds used in factories as a template for making lots of things that are identical. Imagine pouring molten iron into a mould to make a simple iron pot. You might produce a set of instructions to be sold with the pots that tell the owner how to cook using the pot, how to care for it, etc. The same instructions apply to every pot BUT what owners actually do is entirely up to them. Some might make soup, another person a stew, etc. In Python, a class defines the basics of a possible object and some methods that come with it. (Methods are like functions, but apply to things made using the class.) When we want create a Python object using a class, we call it 'creating an instance of a class'. If you have a class called Room, you would create instances like this: lounge = Room() kitchen = Room() hall = Room() As you typically want to store the main dimensions (height, length, width) of a room, whatever it is used for, it makes sense to define that when the instance is created. You would therefore have a method called __init__ that accepts height, length, width and when you create an instance of Room you would provide that information: lounge = Room(1300, 4000, 2000) The __init__ method is called automatically when you create an instance. It is short for initialise (intialize). You can reference the information using lounge.height and so on. These are attributes of the lounge instance. I provided the measurements in mm but you could include a method (function inside a class) that converts between mm and ft. Thus, I could say something like lounge.height_in_ft(). Methods in classes are usually defined with a first parameter of self: def __init__(self, height, length, width): # code for __init__ def height_in_ft(self): # code to return height The self is a shorthand way of referring to an instance. When you use lounge.height_in_ft() the method knows that any reference to self means the lounge instance, so self.height means lounge.height but you don't have to write the code for each individual instance. Thus kitchen.height_in_ft() and bathroom.height_in_ft() use the same method, but you don't have to pass the height of the instance as the method can reference it using self.height EXAMPLE Room class The code shown as the end of this post will generate the following output: Lounge 1300 4000 4000 Snug 1300 2500 2500 Lounge length in feet: 4.26509187 Snug wall area: 11700000 in sq.mm., 125.94 in sq.ft. Note that a method definition that is preceded by the command, @staticmethod (a decorator) is really just a function that does not include the self reference to the calling instance. It is included in a class definition for convenience and can be called by reference to the class or the instance: Room.mm_to_ft(mm) lounge.mm_to_ft(mm) Here's the code for the full programme: class Room(): def __init__(self, name, height, length, width): self.name = name self.height = height self.length = length self.width = width @staticmethod def mm_to_ft(mm): return mm * 0.0032808399 @staticmethod def sqmm_to_sqft(sqmm): return sqmm * 1.07639e-5 def height_in_ft(self): return Room.mm_to_ft(self.height) def width_in_ft(self): return Room.mm_to_ft(self.width) def length_in_ft(self): return Room.mm_to_ft(self.length) def wall_area(self): return self.length * 2 * self.height + self.width * 2 * self.height lounge = Room('Lounge', 1300, 4000, 2000) snug = Room('Snug', 1300, 2500, 2000) print(lounge.name, lounge.height, lounge.length, lounge.length) print(snug.name, snug.height, snug.length, snug.length) print(lounge.name, 'length in feet:', lounge.height_in_ft()) print(f'{snug.name} wall area: {snug.wall_area()} in sq.mm., ' + \ f'{snug.sqmm_to_sqft(snug.wall_area()):.2f} in sq.ft.') Another useful decorator is @property, which allows you to refer to a method as if it is an attribute. Not used in the example, but if I put that before the height_in_ft methods you could say, for example, lounge.height_in_ft instead of lounge.height_in_ft(). One can write classes that are based on other classes. These child classes inherit all of the characteristics of the parent (or super) class but any attribute or method can be overridden to use alternatives that apply only to the child (and its children). Such child classes might have additional methods, alternative __init__ methods, different default output when referenced in a print statement, and so on. The example code code does not demonstrate this feature.
2 of 5
1
THIS VIDEO SEEMS TO BE DEEP IN TO : https://youtu.be/_EljKJHSGis?si=OO2QBUKRe2FNERfM VIST IS
🌐
GeeksforGeeks
geeksforgeeks.org › python › class-method-vs-static-method-vs-instance-method-in-python
Class Method vs Static Method vs Instance Method in Python - GeeksforGeeks
July 23, 2025 - In this example, the MathOperations class features static methods add and subtract for performing basic arithmetic operations. These methods can be directly invoked on the class without creating an instance, providing a convenient and ...
Find elsewhere
🌐
DEV Community
dev.to › gaurbprajapati › class-method-vs-static-method-python-oops-3fek
Class Method Vs Static Method Python OOPS - DEV Community
August 15, 2023 - In this example, the power class method in the MathUtils class takes two parameters, x and n, in addition to the cls argument. what is difference between class method and static method Class methods and static methods are both used in Python ...
🌐
Board Infinity
boardinfinity.com › blog › class-and-static-method-in-python-differences
Class and Static Method in Python: Differences | Board Infinity
January 3, 2025 - A static method in Python means it is a method that belongs to the class. Static methods are class methods and do not have access to attributes on a class or instance of the class at their own instance or to other instances or class attributes.
🌐
Medium
medium.com › codex › python-class-methods-class-vs-instance-vs-static-methods-96d075d27c68
Python Class Methods: Class Vs. Instance Vs. Static Methods | by Benjamin Bennett Alexander | CodeX | Medium
October 26, 2022 - Unlike instance and class methods, static methods cannot access class attributes or instance attributes. In Python, we create a static method using a decorator. We write @staticmethod right above the method we want to decorate.
🌐
Python Engineer
python-engineer.com › posts › difference-classmethod-and-staticmethod
Difference between @classmethod, @staticmethod, and instance methods in Python. - Python Engineer
Use this when you don't need to access variables that belong to an instance, but still need general attributes that belong to the class. Static methods can neither access class variables/methods nor instance variables/methods.
🌐
Spark By {Examples}
sparkbyexamples.com › home › python › python staticmethod vs classmethod
Python staticmethod vs classmethod - Spark By {Examples}
May 31, 2024 - The staticmethod and classmethod decorators are used to define methods that are related to a class but are not specific to any instance of the class. ... A staticmethod in Python is a special type of method that is defined inside a class and is related to the class but does not have access to any instance or class data.
🌐
Flexiple
flexiple.com › python › class-method-vs-static-method
Class Method Vs Static Method - Flexiple - Flexiple
It can be called on the class itself, ... operate at the class level. The static method in Python is a function defined within a class that is not associated with a specific instance or the class itself....
🌐
Accuweb
accuweb.cloud › home › explain class method vs static method in python
Explain Class method vs Static method in Python
April 14, 2024 - In this example, class_method is ... in both instances because it’s affecting the class as a whole. Static methods are like standalone helpers in a class, not tied to a specific instance or the class itself....
🌐
Reddit
reddit.com › r/learnprogramming › static method vs class method
Static method vs Class method : r/learnprogramming
March 10, 2022 - Class methods are good if you have global state you need to share access to (not usually something you want, but it's sometimes useful), and static methods are good if you need to provide helpful utility functions that don't depend on an instance of a class (eg, if you have a Vector class that represents a point in 2D space, a useful static method might be a method to construct one given a length ad angle rather than x and y). ... This is a difference that applies only to Python.
🌐
Wiingy
wiingy.com › home › learn › python › class method vs static method in python
Class Method vs Static Method in Python (With Examples)
January 30, 2025 - This article’s goals are to describe the distinctions between Python’s class methods and static methods and to provide usage examples.
🌐
LinkedIn
linkedin.com › pulse › exploring-differences-between-class-methods-static-python
Exploring the Differences Between Class Methods and Static Methods in Python
February 21, 2023 - Static methods are defined using the @staticmethod decorator. They do not take any special arguments like class methods and are not bound to either the class or the instance. They are often used as utility functions that do not depend on any state from either the class or the instance. Here's an example of a static method that checks if a string is a palindrome:
🌐
MakeUseOf
makeuseof.com › home › programming › instance vs. static vs. class methods in python: the important differences
Instance vs. Static vs. Class Methods in Python: The Important Differences
August 7, 2023 - They can't access specific instance data, but they can call other static methods. Class methods don't need self as an argument, but they do need a parameter called cls. This stands for class, and like self, it gets automatically passed in by Python. Class methods are created using the @classmethod decorator. class DecoratorExample: """ Example Class """ def __init__(self): """ Example Setup """ print('Hello, World!') @classmethod def example_function(cls): """ This method is a class method!