Say you’re writing an Order class for an Ohio bike shop that charges 5.75% sales tax. One method changes that rate for every order; another checks a ZIP code. That’s Python classmethod vs staticmethod in a single class.
Use @classmethod when the method needs the class itself: shared settings, alternate constructors, subclasses. Use @staticmethod when it needs neither the class nor an object, like the ZIP check.
class Order:
@classmethod
def set_tax_rate(cls, rate): ... # gets the class
@staticmethod
def is_valid_zip(zip_code): ... # gets nothing
In this tutorial, I’ll compare the Python classmethod vs staticmethod decorators on that one class. Each output below is a real run on Python 3.12.5, captured in VS Code.
Python classmethod vs staticmethod at a Glance
| Feature | @classmethod | @staticmethod | Instance method |
|---|---|---|---|
| First argument | cls (the class) | None | self (the object) |
| Reads class variables | Yes, through cls | Only by naming the class | Yes, through self |
| Reads one object’s data | No | No | Yes |
| Follows subclasses | Yes | No | Yes |
| Callable inside the class body | No | Yes (Python 3.10+) | No |
| Typical job | Alternate constructors, shared settings | Helpers such as validation | Work on one object |
Instance methods are the third kind people mix up; see the difference between functions and methods in Python.
How to Write a Static Method and a Class Method in a Python Class
Here’s the Order sample with all three method types. A $240.00 order is the running example:
class Order:
tax_rate = 0.0575 # Ohio state sales tax
def __init__(self, subtotal):
self.subtotal = subtotal
def total(self): # instance method: gets self
return round(self.subtotal * (1 + self.tax_rate), 2)
@classmethod
def set_tax_rate(cls, rate): # class method: gets cls
cls.tax_rate = rate
@staticmethod
def is_valid_zip(zip_code): # static method: gets nothing
return len(zip_code) == 5 and zip_code.isdigit()
order = Order(240.00)
print(f"Total at 5.75%: ${order.total():,.2f}")
Order.set_tax_rate(0.0725)
print(f"Total at 7.25%: ${order.total():,.2f}")
print(Order.is_valid_zip("43215"), order.is_valid_zip("4321"))
Output:
Total at 5.75%: $253.80
Total at 7.25%: $257.40
True False

The total goes from $253.80 to $257.40 after Order.set_tax_rate(0.0725), without touching the object. The static method returns True for 43215 and False for 4321.
tax_rate is a class variable. If you haven’t met those yet, see class vs instance variables in Python.
Why Can’t a Static Method See Class Variables?
Same class, but now a static method tries to compute the tax from tax_rate:
class Order:
tax_rate = 0.0575
@staticmethod
def tax_on(subtotal):
return round(subtotal * tax_rate, 2) # no cls, no self
print(Order.tax_on(240.00))
Output:
Traceback (most recent call last):
File "C:\pyguides\pydemo\static_nameerror.py", line 9, in <module>
print(Order.tax_on(240.00))
^^^^^^^^^^^^^^^^^^^^
File "C:\pyguides\pydemo\static_nameerror.py", line 6, in tax_on
return round(subtotal * tax_rate, 2) # no cls, no self
^^^^^^^^
NameError: name 'tax_rate' is not defined

When a method runs, Python checks local and global names, never the class body. My Python variable scope tutorial explains that lookup.
The fix is a class method that reads cls.tax_rate:
class Order:
tax_rate = 0.0575
@classmethod
def tax_on(cls, subtotal):
return round(subtotal * cls.tax_rate, 2)
print(Order.tax_on(240.00))
Output:
13.8
That returns 13.8 ($13.80 on $240.00). Hard-coding Order.tax_rate in a static method also works, but a subclass’s own rate gets ignored.
Which One Returns the Subclass: Class Method or Static Method?
Same Order class, now reading a CSV row, plus a RushOrder subclass with a $25.00 fee:
class Order:
def __init__(self, customer, subtotal):
self.customer = customer
self.subtotal = subtotal
@classmethod
def from_csv(cls, row):
name, amount = row.split(",")
return cls(name, float(amount))
@staticmethod
def from_csv_static(row):
name, amount = row.split(",")
return Order(name, float(amount)) # class is hard-coded
class RushOrder(Order):
fee = 25.00
a = RushOrder.from_csv("Ashley Turner,180.00")
b = RushOrder.from_csv_static("Ashley Turner,180.00")
print("classmethod: ", type(a).__name__, getattr(a, "fee", "no fee"))
print("staticmethod:", type(b).__name__, getattr(b, "fee", "no fee"))
Output:
classmethod: RushOrder 25.0
staticmethod: Order no fee

cls is whatever class you called the method on, so RushOrder.from_csv() builds a RushOrder. The static version hard-codes Order and loses the fee.
That’s why alternate constructors, like pandas’ DataFrame.from_dict(), are class methods. See constructor overloading in Python and my Python classmethod() function tutorial for more.
Calling a Static Method Inside the Class Body (Python 3.10+)
Same Order class again. Since Python 3.10, a static method is callable like a plain function, even while the class is being built:
import sys
class Order:
@staticmethod
def dollars(cents):
return f"${cents / 100:,.2f}"
@classmethod
def label(cls):
return cls.__name__
FREE_SHIPPING = dollars(7500) # fine on Python 3.10+
raw = Order.__dict__
print("Python", sys.version.split()[0], Order.FREE_SHIPPING)
print("staticmethod callable:", callable(raw["dollars"]))
print("classmethod callable: ", callable(raw["label"]))
Output:
Python 3.12.5 $75.00
staticmethod callable: True
classmethod callable: False

FREE_SHIPPING comes out as $75.00. On Python 3.9 and older, that line raises a TypeError.
When to Use a Class Method Instead of a Static Method in Python
My Python rule of thumb:
- Changing a shared setting like
tax_rate: class method. - Building objects from a CSV row, dict or JSON: class method, as in the factory pattern in Python.
- A helper that only uses its arguments, like the ZIP check: static method.
- Anything that reads one order’s data: a regular instance method.
Pro Tip: if a static method never touches the class, a module-level function works just as well.
In short, a Python class method gets the class and follows subclasses, while a static method gets nothing and is just a function stored in the class.
Once the three method types click, these class topics come next:
- Python dataclasses explained
- __new__ vs __init__ in Python
- The singleton pattern in Python
- Abstract base classes in Python
Python classmethod vs staticmethod: Common Questions
What is a static method in Python?
A method marked with @staticmethod. It gets no automatic first argument, so it acts like a plain function stored in the class.
What’s the difference between a static method and an instance method?
An instance method gets self and can read that object’s data; a static method only has its arguments.
Can I call a class method on an instance?
Yes. cls is still the object’s class, so order.set_tax_rate(0.07) changes every order’s rate.
Can a static method call a class method?
Only through the class name, like Order.set_tax_rate(0.07). If it needs the class, make it a class method.
Does Python have static classes?
No. A module of functions fills that role; a class of only static methods rarely adds anything.
Where are classmethod and staticmethod documented?
See staticmethod() in the Python built-in functions reference.

Bijay Kumar is a 13-time Microsoft MVP with more than 18 years in software development, and the founder of Python Guides and TSinfo Technologies. He started out building .NET and SharePoint solutions at HP, TCS and KPIT before moving into Python, machine learning and AI, and he also builds web apps with TypeScript and React. He writes the tutorials here himself, and every example is run before publishing so you see the real output. More about Bijay · Microsoft MVP profile · LinkedIn