Construction is implicit in python, __init__ is used for initialization of a new object. There is a __new__ constructor, but you'll likely not need to write one ever. https://docs.python.org/3/reference/datamodel.html#classes 3.2.8.8. Classes Classes are callable. These objects normally act as factories for new instances of themselves, but variations are possible for class types that override __new__() . The arguments of the call are passed to __new__() and, in the typical case, to __init__() to initialize the new instance. Answer from xelf on reddit.com
🌐
GeeksforGeeks
geeksforgeeks.org › python › constructors-in-python
Constructors in Python - GeeksforGeeks
July 11, 2025 - In Python, a constructor is a special method that is called automatically when an object is created from a class.
🌐
Real Python
realpython.com › python-class-constructor
Python Class Constructors: Control Your Object Instantiation – Real Python
January 19, 2025 - The tool responsible for running this instantiation process is commonly known as a class constructor. ... In Python, to construct an object of a given class, you just need to call the class with appropriate arguments, as you would call any function:
🌐
Refactoring.Guru
refactoring.guru › home › design patterns › creational patterns
Builder
January 1, 2026 - Calling such a beast is very inconvenient; therefore, you overload the constructor and create several shorter versions with fewer parameters. These constructors still refer to the main one, passing some default values into any omitted parameters. class Pizza { Pizza(int size) { ...
🌐
PyTorch
docs.pytorch.org › reference api › torch.utils.data
torch.utils.data — PyTorch 2.11 documentation
At the heart of PyTorch data loading utility is the torch.utils.data.DataLoader class. It represents a Python iterable over a dataset, with support for ... DataLoader(dataset, batch_size=1, shuffle=False, sampler=None, batch_sampler=None, num_workers=0, collate_fn=None, pin_memory=False, drop_last=False, timeout=0, worker_init_fn=None, *, prefetch_factor=2, persistent_workers=False) The sections below describe in details the effects and usages of these options. The most important argument of DataLoader constructor is dataset, which indicates a dataset object to load data from.
Find elsewhere
Top answer
1 of 6
7

I see a misconception here between a constructor--constructing the object and initializing the object:

Python's use of __new__ and __init__?

Use __new__ when you need to control the creation of a new instance. Use __init__ when you need to control initialization of a new instance.

So we must be careful here.

I read that the constructor is like the first argument passed to the class, which makes sense to me since the parameters seem to be passed to the class via the __init__ method.

The constructor is not passed to the class, to be precise the result of the constructor (__new__) will be the first argument for every instance method in the class or its sub-classes (note: __new__ works only for new-style classes):

class A:
    def __new__(self):
            return 'xyz'

See what happens when you call the class (create the object):

>>> A()
'xyz'
>>> type(A())
<class 'str'>

Calling the class no longer return instance of type A, because we changed the mechanism of the constructor __new__. Actually by doing so you alter the whole meaning of your class, not only, this is pretty much hard to decipher. It's unlikely that you'll switch the type of object during the creating time of that specific object. I hope this sentence makes sense, if not, how will it make sense in your code!

class A:
    def __new__(self):
            return 'xyz'

    def type_check(self):
            print(type(self))

Look what happens when we try to call type_check method:

>>> a = A()
>>> a
'xyz'
>>> a.type_check()
AttributeError: 'str' object has no attribute 'type_check'

a is not an object of class A, so basically you don't have access to class A anymore.

__init__ is used to initialize the object's state. Instead of calling methods that will initialize the object's members after it's created, __init__ solves this issue by initializing the object's members during creation time, so if you have a member called name inside a class and you want to initialize name when you create the class instead of calling an extra method init_name('name'), you would certainly use __init__ for this purpose.

So when I 'call' the class, I pass it the parameters from the __init__ method?

When you call the class, you pass the parameters (to) __init__ method?

Whatever arguments you pass the class, all the parameters will be passed to __init__ with one additional parameter added automatically for you which is the implied object usually called self (the instance itself) that will be passed always as the left-most argument by Python automatically:

class A:
    def __init__(self, a, b):
        self.a = a
        self.b = b 

        A(  34,  35) 
 self.a = 34 |    |  
             |    | 
             |    | self.b = 35  
  init(self, a,   b)
        |
        |
        | 
       The instance that you created by calling the class A() 

Note: __init__ works for both classic classes and new style classes. Whereas, __new__ works only for new-style classes.

2 of 6
4

No, the constructor is just the method that is called to construct the object. It is not passed anywhere. Rather the object itself is passed automatically to all methods of the class.

Constructor is not required if you don't have anything to construct but usually you have something to do in the beginning.

🌐
Python
typing.python.org › en › latest › spec › constructors.html
Constructors — typing documentation
If the class is generic and explicitly specialized, the type checker should partially specialize the __new__ method using the supplied type arguments. If the class is not explicitly specialized, class-scoped type variables should be solved using the supplied arguments passed to the constructor call.
🌐
CodeSignal
codesignal.com › learn › courses › python-classes-basics-revision › lessons › constructing-knowledge-python-constructors-and-class-methods
Python Constructors and Class Methods
In Python, the constructor is the method named __init__. It sets up—or constructs—our new objects with the necessary initial states. Here, we upgrade the Robot class with a constructor:
🌐
GitHub
github.com › openai › openai-python
GitHub - openai/openai-python: The official Python library for the OpenAI API · GitHub
These methods return a LegacyAPIResponse object. This is a legacy class as we're changing it slightly in the next major version.
Starred by 30.3K users
Forked by 4.7K users
Languages   Python
🌐
Django
docs.djangoproject.com › en › 6.0 › topics › db › models
Models | Django documentation | Django
This class isn’t going to ever be used in isolation, so Abstract base classes are what you’re after. If you’re subclassing an existing model (perhaps something from another application entirely) and want each model to have its own database table, Multi-table inheritance is the way to go. Finally, if you only want to modify the Python-level behavior of a model, without changing the models fields in any way, you can use Proxy models.
🌐
Python.org
discuss.python.org › ideas
Add automatic constructor for classes - Ideas - Discussions on Python.org
July 17, 2024 - In practice most constructor implementations are trivial in that they simply map self attributes to correspondingly named parameters. class Foo: x: int y: int z: int def __init__(self, x: int, y: int, z: int): self.x = x self.y = y self.z = z The typical workflow consists of a) annotating the types for each attribute, b) creating parameters for said attributes, c) assigning attributes to the parameters.
🌐
Playwright
playwright.dev › fixtures
Fixtures | Playwright
import type { Page } from '@playwright/test'; export class SettingsPage { constructor(public readonly page: Page) { } async switchToDarkMode() { // ...
🌐
Python documentation
docs.python.org › 3 › tutorial › classes.html
9. Classes — Python 3.14.3 documentation
Classes provide a means of bundling data and functionality together. Creating a new class creates a new type of object, allowing new instances of that type to be made. Each class instance can have ...
🌐
Medium
lewoudar.medium.com › a-simple-way-to-have-many-class-constructors-in-python-da82a29b64cd
A simple way to have many class constructors in Python | by Kevin Tewouda | Medium
March 3, 2024 - #include <iostream> #include <vector> #include <map> using namespace std; class Point { private: int x; int y; public: // Constructor with two separate parameters for x and y Point(int x, int y) { this->x = x; this->y = y; } // Constructor with a vector having x and y Point(vector<int> vec) { if (vec.size() != 2) { throw invalid_argument("The vector should have only two elements represeting x and y coordinates."); } x = vec[0]; y = vec[1]; } // Constructor with a dict (std::map in C++) Point(map<string, int> dict) { x = dict["x"]; y = dict["y"]; } // Method to display the Point void displayPoint() { cout << "Point: (" << x << ", " << y << ")" << endl; } }; int main() { Point p1(1, 2); p1.displayPoint(); vector<int> vec = {3, 4}; Point p2(vec); p2.displayPoint(); map<string, int> dict = {{"x", 5}, {"y", 6}}; Point p3(dict); p3.displayPoint(); return 0; }
🌐
Tutorialspoint
tutorialspoint.com › python › python_constructors.htm
Python - Constructors
Python constructor is an instance method in a class, that is automatically called whenever a new object of the class is created. The constructor's role is to assign value to instance variables as soon as the object is declared.
🌐
Esri Developer
developers.arcgis.com › javascript › latest › references › core › Map
Map | References | ArcGIS Maps SDK for JavaScript
See the properties table for a list of all the properties that may be passed into the constructor.
🌐
Godot Engine
docs.godotengine.org › en › stable › tutorials › scripting › gdscript › gdscript_basics.html
GDScript reference — Godot Engine (stable) documentation in English
GDScript is a high-level, object-oriented, imperative, and gradually typed programming language built for Godot. It uses an indentation-based syntax similar to languages like Python. Its goal is to...
🌐
FastAPI
fastapi.tiangolo.com
FastAPI
FastAPI is a modern, fast (high-performance), web framework for building APIs with Python based on standard Python type hints.
🌐
DigitalOcean
digitalocean.com › community › tutorials › python-classes-objects
Python Classes and Objects | DigitalOcean
August 4, 2022 - You may also print messages in the constructor to be confirmed whether the object has been created. We shall learn a greater role of constructor once we get to know about python inheritance. The constructor method starts with def __init__. Afterward, the first parameter must be ‘self’, as it passes a reference to the instance of the class itself.