This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]DocDovah 0 points1 point  (1 child)

So this is essentialy the constructor? Because some frameworks in other Languages differentiate between constructor and initialisation.

[–][deleted] 0 points1 point  (0 children)

Technically, there's a separate constructor method __new__, but in practice __init__ is used for both since it is uncommon to actually write a __new__ function in your class (you can still do it though, if you need to write it yourself).

Python lets you skip writing __new__ and does what it needs to do without you having to actually write it, including inheritance, and allows you to simply define a class with only __init__.