On Jul 22, 9:26 am, Catherine Heathcote
<[EMAIL PROTECTED]> wrote:
> If I create a new class inherited from another with a constructor, what
> happens with the new class's constructer?
> Thanks for your time.

Nothing, unless you call it in your constructor.

class Base(object):
 def __init__(self):
  print "Base constructor called"

# without calling the base class constructor
class C(Base):
 def __init__(self):
  print "C constructor called"

# call the base class constructor using super
class D(Base):
 def __init__(self):
  super(D, self).__init__()
  print "D constructor called"

c = C()
d = D()


Matt
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to