[Chicago] create all classes

Kumar McMillan kumar.mcmillan at gmail.com
Mon Feb 18 19:33:42 CET 2008


On Feb 18, 2008 12:26 PM, Lukasz Szybalski <szybalski at gmail.com> wrote:
> class B? Is the init of class A never run? Why overloading doesn't run
> init from A then init from B?

because it's not automatic, you have to explicitly call the super
method.  Change:

class B(A):
  def __init__(self):
       pass

to:

class B(A):
  def __init__(self):
       A.__init__(self)

or:

class A(object):
    # ... etc ...

class B(A):
    def __init__(self):
        super(B, self).__init__()

the latter is preferable and the difference is that you are using
new-style classes (inheriting from class type object).


More information about the Chicago mailing list