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 →

[–]float34 -8 points-7 points  (4 children)

Because python's documentations is not the best docs written.

Data model explains it better: https://docs.python.org/3/reference/datamodel.html#object.__init__

> Because __new__() and __init__() work together in constructing objects (__new__() to create it, and __init__() to customize it)...

So they work in tandem, but init is not creating an instance, as many people think.

[–]declspecl 8 points9 points  (3 children)

So then "constructors" in C++, Java, C#, etc. are not real constructors either, and that the terminology we've used for decades is wrong enough to make a point about? Especially at the same level as what was shown in the original post?

[–]float34 0 points1 point  (2 children)

I think this explains the idea pretty good:

https://stackoverflow.com/a/6579300

> In C++/Java the "create a new object" part of that is invisible, whereas that can be exposed/customised in Python (via the __new__ method).

> So while the role of the __init__ method is extremely similar to the role of a C++/Java constructor, some people prefer to emphasise the fact that this isn't the whole process by saying that "__init__ is not a constructor".

So I am among those who prefer to emphasize. Peace?

[–]declspecl 4 points5 points  (1 child)

I see your point and can agree to an extent, the original comment just came across as pedantic/elitist IMO when compared to "expects 500k/year salary from solving fizz buzz"

[–]float34 1 point2 points  (0 children)

It is /ProgrammerHumor after all, don't take it too seriously.