Is this not infinite?

John Salerno johnjsal at NOSPAMgmail.com
Mon Mar 6 20:23:30 EST 2006


 From a book:

class Derived(Base):
     def __init__(self, etc....):
         self.__init__(self, etc...)

I don't understand why the 'self' in the call to the Base class 
constructor doesn't still refer to the Derived instance. If you say:

x = Derived()

then that triggers the def above. And then that function calls a 
constructor, but if it's calling x.__init__, and x is a Derived 
instance, it seems like the function keeps calling itself.

Obviously I'm missing a piece of information that would help me to see 
why the call gets passed back up to Base...



More information about the Python-list mailing list