multiple inharitance super() question

Alex Greif alex.greif at gmail.com
Mon Nov 14 13:28:39 CET 2005


Hi,

Before 2.2 I could initialize multiple super classes like this:
class B(A,AA):
    def __init__(self, args):
        A.__init__(self,args)
        AA.__init__(self,args)

Tutorials say that since python 2.2 superclasses should be initialized
with the super() construct.

class A(object):
    def __init__(self, args):
        ...

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


BUT what happens if B extends from A and AA like:

class A(object):
    def __init__(self, args):
        ...

class AA(object):
    def __init__(self, args):
        ...

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


How can I tell that B.__init__() should initialize A and AA?
Or is the new super() so clever to call A.__init__() and AA.__init__()
internally?

thanks,
Alex Greif


________________________________________
http://www.fotobuch-xxl.de/



More information about the Python-list mailing list