I've been wondering why the __init__ method is labeled as 'init' when it's really called after the object is instantiated. Shouldn't it be called __inst__ instead? It's a bit frustrating to me. Am I missing something, is there a technical reason behind it, or is it just traditional naming?
5 Answers
You're totally right about the distinction! __new__ is called first to allocate memory and create the object, while __init__ is where you initialize the object's settings. So, by the time you get to __init__, the object exists and that's why it takes 'self' as an argument.
The thing is, the __new__ method is what actually creates the object—this is known as instantiation. Once the object is created, __init__ is called to set everything up, hence why it’s considered initialization. So, they really serve two different purposes in the object lifecycle.
Just to clarify, __init__ has that name because it's about initializing the attributes of the new instance once it exists. Some languages might use different terms, but this is how it’s handled in Python. It's normal to have these naming conventions!
It's important to understand the difference between instantiation and initialization. Instantiation is when the object is created (via __new__), and initialization is when it's set up (via __init__). They aren’t the same, even if they happen closely together.
If you're confused about the terms, think of it like this: creating an object is instantiation, and setting its initial values is initialization. That’s why we call it __init__! It's all part of the lifecycle of an object.

Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically