instance creatiion as an "event"

Arthur ajsiegel at
Wed Apr 23 00:35:58 CEST 2003

Alex writes:

>Not with the once-habitual Python idiom for that purpose. Try it!

>class TestPoint:
>   def __init__(self):
> = 23
>      self.redraw()
>   def redraw(self):
>     print 'TestPoint.redraw',

>class PointChild(TestPoint):
>   def __init__(self):
>      self.pc = 42
>      TestPoint.__init__(self)
>   def redraw(self):
>     print 'PointChild.redraw',, self.pc

>p = PointChild()

Indeed.  The behavior I intuitively expected is indeed what one get's and I
was off somewhere in la-la land misundertanding my error messages. Deja vu,

And as it turns out,  a little experimentation indicates more thought as to
when in sub's __init__ its parent's __init__ is called might indeed be the
full answer to my issue.

A little simpler than I had hoped ;)


More information about the Python-list mailing list