datarekha
Python Easy Asked at GoogleAsked at AmazonAsked at MetaAsked at Microsoft

What is the difference between an instance method, a class method, and a static method in Python?

The short answer

Instance methods receive the instance as the first argument (`self`) and can read and modify instance state. Class methods receive the class as the first argument (`cls`) via `@classmethod` and are used for alternative constructors or class-level operations. Static methods receive no implicit argument and are plain functions namespaced inside a class.

How to think about it

How to think about it

The question is really: what implicit argument does Python inject, and why? Think of it as a routing decision Python makes before your function body runs.

  • No decorator → instance method → Python passes the calling instance as self
  • @classmethod → Python passes the class itself as cls
  • @staticmethod → Python passes nothing extra; it’s a plain function

All three in one class

Quick reference

First argDecoratorTypical use
InstanceselfnoneRead/write instance state
Classcls@classmethodAlternative constructors, class-level state
Static@staticmethodUtilities that don’t touch self or cls

The key insight: why cls matters in @classmethod

Inside a @classmethod, using cls(...) instead of hardcoding Circle(...) means the method works correctly when subclassed. If Sphere extends Circle and calls Sphere.from_diameter(10), cls is Sphere so the factory returns a Sphere instance, not a Circle. Hardcoding the class name breaks this.

Learn it properly Classes & Instances

Keep practising

All Python questions

Explore further

Skip to content