__init__ explanation please

Hrvoje Niksic hniksic at xemacs.org
Tue Jan 15 05:15:18 EST 2008


Bruno Desthuilliers <bruno.42.desthuilliers at wtf.websiteburo.oops.com>
writes:

> 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 !-)

I agree with this.  The poster I was responding to called __init__
"akin to a constructor", which (to me) implied connection to other
languages, not aspiration to define __init__ as THE constructor.



More information about the Python-list mailing list