What method is used to initialize a new instance of a class in Python?

The story behind the answer

The `__init__` method initializes a new instance of a Python class.

When code calls a class, Python’s object-construction process normally invokes `__new__()` first to create the instance, then calls `__init__()` to configure that already-created object. Typical initialization assigns instance attributes, validates arguments, or prepares related state. For example, `self.name = name` inside `__init__` gives each object its own `name` attribute.

The method receives the new object as `self` and the arguments passed to the class call. It must return `None`; returning another value causes a `TypeError`. If a subclass defines its own initializer, it may need to call `super().__init__()` so the base class is initialized too.

A frequent mix-up is calling `__new__()` the initializer: it is responsible for creating or choosing the object, especially for immutable types such as `int` or `str`. `__str__()` controls readable text output, and `__call__()` lets an instance be invoked like a function.

Source: Wikipedia · fact-checked Aug. 2026

Add question to a list

Choose a list to keep this question in: