Class vs object — blueprint vs instance
WHAT are we talking about?
WHY does this distinction exist?
WHY split blueprint from instance?
- Reuse — write the description once, stamp out many objects.
- Independent state — each object keeps its own data; changing one doesn't corrupt others.
- Shared behaviour — methods are stored once (on the class), so 1000 objects don't each store 1000 copies of the code.
HOW do you build and use them?
class Dog: # blueprint begins
species = "Canis" # CLASS attribute (shared by all dogs)
def __init__(self, name, age): # the constructor
self.name = name # INSTANCE attribute (per object)
self.age = age
def bark(self): # behaviour
return f"{self.name} says Woof!"
d1 = Dog("Rex", 3) # instantiation -> an OBJECT
d2 = Dog("Fido", 5) # another OBJECT, independent stateHOW instantiation works, step by step:
Dog("Rex", 3)asks Python to create a blank object of typeDog.- Python calls
__init__withself= the new blank object. self.name = namewrites data into that object.- The finished object's reference is handed back and stored in
d1.

Worked Examples
Common Mistakes
Recall Feynman: explain to a 12-year-old
A class is like a cookie cutter. The cutter is not a cookie — it's the shape. Every time you press it into dough you get a cookie (an object). All the cookies have the same shape (same class), but you can sprinkle different toppings on each one (different data). Throwing one cookie away doesn't hurt the others, and you still have the cutter to make more.
Flashcards
What is a class?
What is an object?
What is instantiation?
Dog("Rex", 3), which triggers __init__.Where do instance attributes live?
self.x = ...), separate per object.Where do class attributes live?
Why doesn't changing d1.age affect d2.age?
What does a is b test for two equal-looking objects?
Does writing a class create any object?
Why store methods on the class, not each object?
Connections
- Constructors and __init__ — how an object is initialised at instantiation.
- self and instance methods — how
selfbinds methods to a specific object. - Class vs instance attributes — the shared-vs-own data distinction.
- Encapsulation — why bundling data+behaviour into a class matters.
- Identity vs Equality (is vs ==) — distinguishing objects.
- Memory model and references — where objects actually live.
Concept Map
Hinglish (regional understanding)
Intuition Hinglish mein samjho
Dekho, class ek blueprint hota hai — jaise architect ka drawing ya cookie cutter. Wo sirf describe karta hai ki cheez kaisi dikhegi: uske paas kaunse data (attributes) honge aur kaunse kaam (methods) wo kar sakti hai. Lekin class khud koi real cheez nahi hai, sirf plan hai. Jab tak aap Dog("Rex", 3) likh kar use call nahi karte, koi actual dog memory mein nahi banta.
Jab aap class ko call karte ho, tab ek object (instance) banta hai — yahi asli cheez hai jo memory mein rehti hai. Is process ko instantiation kehte hain. Har object ke paas apna alag data hota hai. d1.age = 4 karne se sirf d1 change hota hai, d2 ko kuch nahi hota — kyunki instance attributes har object ke andar alag-alag store hote hain. Yeh self.name = name wali line har naye object ke liye fresh chalti hai.
Ek important baat: methods aur class attributes class par store hote hain, ek hi copy, sabhi objects share karte hain. Isliye 1000 dogs banao to code 1000 baar copy nahi hota — memory bachti hai. Aur identity ka funda yaad rakho: a is b check karta hai ki dono same memory cell hain ya nahi. Do alag Dog("Rex",3) banao, data same ho tab bhi a is b False hoga, kyunki wo do alag objects hain.
Yeh distinction OOP ki neev hai. "Class = Cutter, Object = Cookie" yaad rakhna — ek cutter se kitni bhi cookies, sab same shape, par har ek pe alag sprinkles. Ye samajh gaye to constructors, self, encapsulation sab clear ho jayega.