fbpx

What is the purpose of the __init__ method in Python classes?

The __init__ method is a special method in Python classes that is automatically called when an object is created. It initializes the object's attributes and sets up its initial state. Here's a simple example:

class MyClass:
    def __init__(self, name):
        self.name = name

obj = MyClass("Rama")

 

# Dream job to realty