[Tutor] Contructor Overloading and Function Tooktips

John Fouhy jfouhy at paradise.net.nz
Sat Apr 16 00:20:48 CEST 2005

Gooch, John wrote:
  > Is there a way to create multiple __init__ routines in a Python Class?

Not directly (well, not that I know of).  But you can always emulate it.


class Foo(object):
   def __init__(self, init, *args, **kw):
     if init == 'this':
       self._initThis(*args, **kw)
     elif init == 'that':
       self.initThat(*args, **kw)


If you're using inheritance, you'll need to do a little more work inside 
each branch of the if statement.


More information about the Tutor mailing list