Introduction
In Object-Oriented Programming (OOP), a class is like a blueprint or template for creating objects.
- Think of a class as a design for a car.
- An object (also called an instance) is the actual car you build from that blueprint.
Inside a class, we can define different types of methods.
Methods are just functions that live inside a class and describe what the object or the class can do.
There are three main types of methods:
- Instance Methods
- Class Methods
- Static Methods
A quick comparison:
Method type | First parameter | Can access instance attributes? | Can access class attributes? | Typical use cases |
Instance | self | Yes | Yes | Behaviour tied to a single object |
Class | cls | No | Yes | Factory methods; class‑wide configuration |
Static | none | No | No | Utility functions unrelated to class or instance |
‣
Class Instance Methods
‣
Class Methods
‣
Static Methods
‣