bruno at modulix wrote: > [EMAIL PROTECTED] wrote: > > I was wondering, why you always have to remember to call bases' > > constructors > > <pedantic> > s/constructors/__init__/ > > the __init__() method is *not* the constructor. Object's instanciation > is a two-stage process: __new__() is called first, then __init__(). > </pedantic>
You know, Python's __init__ has almost the same semantics as C++ constructors (they both initialize something that's already been allocated in memory, and neither can return a substitute object). I actually think constructors are misnamed in C++, they should be called initializers (and destructors finalizers). The only thing is that C++ doesn't always call operator new when constructing objects, whereas Python always calls __new__, so you can put some initialization in __new__ if you want. Other than that I'd say that Python __init__ is analogous to Java and C++ constructors, but is not a constructor because C++ and Java constructors are not constructors. :) And Java has pointers, not references. :) A-rose-by-any-other-name-ly yr's, Carl Banks -- http://mail.python.org/mailman/listinfo/python-list