Great addition to the __init__() vs __new__() topic. My views were based on the practical understanding and I was being pretty restrictive when I said __new__() was the real constructor. I made this claim observing the fact that whenever you instantiate, in the backend, Python calls in __new__() first. Then, its the __new__() which "privately" calls __init__().
Yes, I strongly agree that both are called in while creating an object. The reason I was being defensive with __new__ is due to the strict definition of constructor I mentioned in the post and the fact that class makes an implicit call to __new__() while instantiating the object.
Again, this is purely debatable. It depends on the degree of freedom you add into the definition of constructor and purpose for which one had been using constructors for.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Great addition to the
__init__()vs__new__()topic. My views were based on the practical understanding and I was being pretty restrictive when I said__new__()was the real constructor. I made this claim observing the fact that whenever you instantiate, in the backend, Python calls in__new__()first. Then, its the__new__()which "privately" calls__init__().Yes, I strongly agree that both are called in while creating an object. The reason I was being defensive with
__new__is due to the strict definition of constructor I mentioned in the post and the fact that class makes an implicit call to__new__()while instantiating the object.Again, this is purely debatable. It depends on the degree of freedom you add into the definition of constructor and purpose for which one had been using constructors for.