obj3 = MyClass()
(it's the () that creates the object, not the =)
_ _new__ is the constructor: it creates the instance and returns it (overriding: advanced topic)
Along the way, it calls _ _init__ on the *already-created* instance, to
ask it to initialise itself ready for use. So, _ _init__ is an
"initialiser" for the instance, used often. Rarely you override _ _new__, but customizing _ _init__ is common: http://www.python.org/doc/ref/customization.html
obj = mytype.__new__(*args, **kwds)
if isinstance(obj, mytype):
mytype.__init__(obj, *args, **kwds)
return obj
Nevertheless, _ _init__ doesn't construct anything. You can even call
it to reinitialize an existing object.
Also, how can a constructor require 'self' as an argument...?
_ _init__(self, ...)
If the _ _init__ function is called by the constructor it cannot return a
value. However if called as a normal function, it can return a value.
_ _init__ is just a function that gets called during the construction