function overloading

Simon Burton simonb at webone.com.au
Wed Jul 2 04:47:00 CEST 2003


Yes, it's a good idea; and that's how i started; i just can't remember all the different names.
Lazy init is a good idea too... But it adds a level to the class
invariant.
It seems i am the lazy one:

def __init__(self,*args,**kwargs):
  read_and_dispatch( args, kwargs, (self.init1,self.init2, ... ) )

was what i had in mind, but unless each init has a different signature,
it's gonna get more hairy:

class Signature:
  def __init__( self, siglist ):
    pass

class TypeSignature:
  pass

class InstanceSignature:
  pass

blah.

Simon Burton.


On Tue, 01 Jul 2003 16:03:17 -0400, John Roth wrote:

> 
> I'd subclass it. I see three classes here:
> 
> class Image:
>     def __init__(self, oldImage)
> 
> class NewImage(Image):
>     def __init__(self, height, width):
> 
> class ImageFromDisk(Image):
>     def __init__(self, fileName):
> 
> The subclasses only override the __init__ method
> of the base class.
> 
> An alternate method of dealing with the situation
> is to do lazy initialization. In other words, don't provide
> any parameters on the construction, and provide three
> different methods for initializing the resulting object.
> 
> John Roth





More information about the Python-list mailing list