instance creatiion as an "event"

Arthur ajsiegel at optonline.net
Tue Apr 22 16:54:17 CEST 2003


I had written -

>Standalone, yes. But, unless I'm missing something, the effects in an
>inheritance chain is different. If I inherit from TestPoint, and need to
>call TestPoint.__init__ in the Point_Child.__init__ to pick up
initilization
>routines common to the chain, I will now unavoidably be calling TestPoint's
>redraw method before I call Point_Child's.

So I'm thinking I should perhaps go back to a fundamentally different
scheme.  Instead of factory functions calling classes based on argument
composition - and therefore lots of classes and attendant inheritance
issues, there should be master classes with alternative redraw methods that
are selected in __init__ on the basis of the argument composition:

In effect:

class Point:
def __init__(self,*args):
   if args are 3 planes:
      self.redraw = self.redraw_from_planes
       elif  args are 2 lines:
            self.redraw = self.redraw_from_lines
        ...
       self.redraw()

I had experimented with this at one point and found it workable.  But went
to a factory function scheme, probably for no better reason then I thought
it was a more standard approach to the general issue I faced.  Serves me
right (if I am now right).

Art








More information about the Python-list mailing list