The difference is only apparent when accessing the method through an instance of A, i.e. A().f(1, 2). f, being a static method, would behave exactly the same as when accessing it through the class. g, being a regular instance method, would automatically be passed the instance as the argument for x. So A().g(1, 2) would result in a TypeError, as it'd receive a total of three arguments. There's a final type of method, class methods using the @classmethod decorator, that are automatically passed a reference to the class they're accessed through, whether that's through the class directly or via one of its instances: class A: @classmethod def h(cls, x, y): return x + y A.h(1, 2) # cls = A A().h(1, 2) # same thing That's useful if the method call happens on a subclass of A, since the argument passed to h would be that subclass. To be honest, in most situations something should either be a class method, an instance method, or not a method, at all. In my experience, there's very few reasons to have static methods. Answer from Spataner on reddit.com
🌐
DigitalOcean
digitalocean.com › community › tutorials › python-static-method
Python staticmethod: When and How to Use Static Methods | DigitalOcean
September 16, 2025 - Static methods in Python are extremely similar to python class level methods, the difference being that a static method is bound to a class rather than the objects for that class. This means that a static method can be called without an object for that class.
Top answer
1 of 12
2349

Yep, using the staticmethod decorator:

class MyClass(object):
    @staticmethod
    def the_static_method(x):
        print(x)

MyClass.the_static_method(2)  # outputs 2

Note that some code might use the old method of defining a static method, using staticmethod as a function rather than a decorator. This should only be used if you have to support ancient versions of Python (2.2 and 2.3):

class MyClass(object):
    def the_static_method(x):
        print(x)
    the_static_method = staticmethod(the_static_method)

MyClass.the_static_method(2)  # outputs 2

This is entirely identical to the first example (using @staticmethod), just not using the nice decorator syntax.

Finally, use staticmethod sparingly! There are very few situations where static-methods are necessary in Python, and I've seen them used many times where a separate "top-level" function would have been clearer.


The following is verbatim from the documentation::

A static method does not receive an implicit first argument. To declare a static method, use this idiom:

class C:
    @staticmethod
    def f(arg1, arg2, ...): ...

The @staticmethod form is a function decorator – see the description of function definitions in Function definitions for details.

It can be called either on the class (such as C.f()) or on an instance (such as C().f()). The instance is ignored except for its class.

Static methods in Python are similar to those found in Java or C++. For a more advanced concept, see classmethod().

For more information on static methods, consult the documentation on the standard type hierarchy in The standard type hierarchy.

New in version 2.2.

Changed in version 2.4: Function decorator syntax added.

2 of 12
261

I think that Steven is actually right. To answer the original question, then, in order to set up a class method, simply assume that the first argument is not going to be a calling instance, and then make sure that you only call the method from the class.

(Note that this answer refers to Python 3.x. In Python 2.x you'll get a TypeError for calling the method on the class itself.)

For example:

class Dog:
    count = 0 # this is a class variable
    dogs = [] # this is a class variable

    def __init__(self, name):
        self.name = name #self.name is an instance variable
        Dog.count += 1
        Dog.dogs.append(name)

    def bark(self, n): # this is an instance method
        print("{} says: {}".format(self.name, "woof! " * n))

    def rollCall(n): #this is implicitly a class method (see comments below)
        print("There are {} dogs.".format(Dog.count))
        if n >= len(Dog.dogs) or n < 0:
            print("They are:")
            for dog in Dog.dogs:
                print("  {}".format(dog))
        else:
            print("The dog indexed at {} is {}.".format(n, Dog.dogs[n]))

fido = Dog("Fido")
fido.bark(3)
Dog.rollCall(-1)
rex = Dog("Rex")
Dog.rollCall(0)

In this code, the "rollCall" method assumes that the first argument is not an instance (as it would be if it were called by an instance instead of a class). As long as "rollCall" is called from the class rather than an instance, the code will work fine. If we try to call "rollCall" from an instance, e.g.:

rex.rollCall(-1)

however, it would cause an exception to be raised because it would send two arguments: itself and -1, and "rollCall" is only defined to accept one argument.

Incidentally, rex.rollCall() would send the correct number of arguments, but would also cause an exception to be raised because now n would be representing a Dog instance (i.e., rex) when the function expects n to be numerical.

This is where the decoration comes in: If we precede the "rollCall" method with

@staticmethod

then, by explicitly stating that the method is static, we can even call it from an instance. Now,

rex.rollCall(-1)

would work. The insertion of @staticmethod before a method definition, then, stops an instance from sending itself as an argument.

You can verify this by trying the following code with and without the @staticmethod line commented out.

class Dog:
    count = 0 # this is a class variable
    dogs = [] # this is a class variable

    def __init__(self, name):
        self.name = name #self.name is an instance variable
        Dog.count += 1
        Dog.dogs.append(name)

    def bark(self, n): # this is an instance method
        print("{} says: {}".format(self.name, "woof! " * n))

    @staticmethod
    def rollCall(n):
        print("There are {} dogs.".format(Dog.count))
        if n >= len(Dog.dogs) or n < 0:
            print("They are:")
            for dog in Dog.dogs:
                print("  {}".format(dog))
        else:
            print("The dog indexed at {} is {}.".format(n, Dog.dogs[n]))


fido = Dog("Fido")
fido.bark(3)
Dog.rollCall(-1)
rex = Dog("Rex")
Dog.rollCall(0)
rex.rollCall(-1)
🌐
Real Python
realpython.com › instance-class-and-static-methods-demystified
Python's Instance, Class, and Static Methods Demystified – Real Python
March 17, 2025 - These are the most common methods in Python classes. Class methods use a cls parameter pointing to the class itself. They can modify class-level state through cls, but they can’t modify individual instance state. Static methods don’t take self or cls parameters.
🌐
Python documentation
docs.python.org › 3 › library › functions.html
Built-in Functions — Python 3.14.4 documentation
February 27, 2026 - Changed in version 3.10: Static methods now inherit the method attributes (__module__, __name__, __qualname__, __doc__ and __annotations__), have a new __wrapped__ attribute, and are now callable as regular functions.
🌐
Real Python
realpython.com › ref › glossary › static-method
static method | Python Glossary – Real Python
In Python, a static method is a method that belongs to a class but doesn’t operate on an instance or the class itself.
🌐
Tutorialspoint
tutorialspoint.com › python › python_static_methods.htm
Python - Static Methods
In Python, a static method is a type of method that does not require any instance to be called. It is very similar to the class method but the difference is that the static method doesn't have a mandatory argument like reference to the object ...
Find elsewhere
🌐
StrataScratch
stratascratch.com › blog › how-to-define-and-use-static-methods-in-python
How to Define and Use Static Methods in Python - StrataScratch
July 21, 2025 - Unlike normal methods, a static method doesn’t care about the object or its data. It is more similar to regular functions, but they are defined inside a class. When you write methods in Python inside a class, you typically use “self”. That is how the technique knows which object it is working with.
🌐
GitHub
github.com › bendmorris › static-python
GitHub - bendmorris/static-python: A fork of cpython that supports building a static interpreter and true standalone executables · GitHub
A fork of cpython that supports building a static interpreter and true standalone executables - bendmorris/static-python
Starred by 202 users
Forked by 23 users
Languages   Python 57.8% | C 35.3% | Objective-C 3.7% | Assembly 1.5% | Shell 1.1% | C++ 0.5%
🌐
GeeksforGeeks
geeksforgeeks.org › python › class-method-vs-static-method-python
Class method vs Static method in Python - GeeksforGeeks
3 weeks 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.
🌐
Hostman
hostman.com › tutorials › python static method
Python Static Methods: Explained with Examples
April 16, 2025 - A static method in Python is bound to the class itself rather than any instance of that class.
Price   $
Address   1999 Harrison St 1800 9079, 94612, Oakland
🌐
Better Stack
betterstack.com › community › questions › static-methods-in-python
How to Create Static Methods in Python? | Better Stack Community
June 19, 2024 - In Python, a static method is a method that belongs to a class but does not operate on instances of that class. Unlike instance methods, static methods do not have access to the instance (self) or class (cls) variables.
🌐
Radek
radek.io › posts › static-variables-and-methods-in-python
Static variables and methods in Python
All variables defined on the class level in Python are considered static.
🌐
Medium
medium.com › @abhishekjainindore24 › navigating-the-world-of-static-methods-and-static-variables-in-python-8f3a36072fd3
Navigating the World of Static Methods and Static Variables in Python | by Abhishek Jain | Medium
February 6, 2024 - Navigating the World of Static Methods and Static Variables in Python Static Methods in Python: Definition: A static method is a method associated with a class rather than an instance of the class
🌐
Programiz
programiz.com › python-programming › methods › built-in › staticmethod
Python staticmethod()
The staticmethod() returns a static method for a function passed as the parameter.
🌐
Kaushik's Blog
kaushiksamba.bearblog.dev › static-methods-in-python-yay-or-nay
Static methods in Python, yay or nay? | Kaushik's Blog
June 20, 2024 - Suggest making this a staticmethod since it's not a stateful operation; it just takes some arguments and packages them into a new message. That would, in turn, make this easier to test.
🌐
Python Reference
python-reference.readthedocs.io › en › latest › docs › functions › staticmethod.html
staticmethod — Python Reference (The Right Way) 0.1 documentation
staticmethods can be used when the code that belongs to a class doesn’t use the object itself at all. Python doesn’t have to instantiate a bound method for each object we instantiate. Bound methods are objects too, and creating them has a cost. Having a static method avoids that.
🌐
Dive into Python
diveintopython.org › home › learn python programming › classes in python › static class and methods
Static Classes in Python - How to Call Static Methods, Use Static Variables
May 3, 2024 - In this article, we will explore the concept of static classes and how to create and call a static method in a class. Python static class is a class that does not require an instance to be created.