Core Concept Mastery • Python Visual Series Module
The `__init__` method is a special method that Python automatically calls every time you create a new object. It is used to initialize the object's attributes with starting values. Think of it as the "setup routine" for your new object.
class Dog:
def __init__(self, name, age):
self.name = name
self.age = age
my_dog = Dog("Rex", 3)
print(my_dog.name)
print(my_dog.age)
This Dog class has a special method called __init__. Python calls it automatically every time you create a new Dog object. It's the "setup routine" that initializes the object's data.