In article <[EMAIL PROTECTED]>, Duncan Booth <[EMAIL PROTECTED]> wrote:
>Carl Banks wrote: > >> 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). > >There is a significant difference: imagine B is a base type and C a >subclass of B: > >When you create an object of type C in Python, while B.__init__ is >executing self is an object of type C (albeit without all the attributes >you expect on your C). > >In C++ when the B() constructor is executing the object is an object of >type B. It doesn't become a C object until the C() constructor is >executing. > >In other words, the object is constructed in Python before any __init__ is >called, but in C++ it isn't constructed until after all the base class >constructors have returned. But if "construction" is what a constructor does, then you're wrong. -- http://mail.python.org/mailman/listinfo/python-list