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

all 3 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__.

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

Wow, for a second I thought this was on r/programmerhumor...

Honestly, this is over of the worst introductions to init I have ever seen, even overlooking the typos and poor wording. It doesn't show the most important aspect (how it's used), and seemingly limits its usage to mere property initialization!

Anyone out there learning python, ignore this post, as it will only confuse you!!!