Hrvoje Niksic a écrit : > Ben Finney <[EMAIL PROTECTED]> writes: > >> Hrvoje Niksic <[EMAIL PROTECTED]> writes: >> >>> Wildemar Wildenburger <[EMAIL PROTECTED]> writes: >>>> __init__() /initializes/ an instance (automatically after >>>> creation). It is called, /after/ the instance has been constructed >>> I don't understand the purpose of this "correction". After all, >>> __init__ *is* the closest equivalent to what other languages would >>> call a constructor. >> No. That would be '__new__', which actually constructs the instance, > > That's not what other OO languages (C++, Java) actually call a > constructor,
There are actually quite a few other OOPLs than C++ and Java, and at least one of them (namely Smalltalk, which predates both C++ and Java) uses distinct phases for allocation and initialisation. IOW, it's not because C++ and/or Java use a given terminology that this terminology should be blindly applied to each and every other OOPL. FWIW, there are quite a lot of other differences between C++/Java and Python when it comes to object model, and what OO is is definitively *not* defined by C++ and/or Java. So while it's true that __init__ is the closest equivalent to what C++ and Java (and possibly a couple "other languages") call a constructor, it doesn't imply that you should refer to it as "the constructor". As Neil Cerutti points out, there's in fact nothing like a 'constructor method' in Python : there are a "__new__" method, an "__init__" method, and "constructor expressions" which may invoke them !-) -- http://mail.python.org/mailman/listinfo/python-list