Peter Otten wrote:

Child()

child father mother parent # <-- parent only once <__main__.Child object at 0x402ad38c>


D-uh?

################################################
class Parent(object):
    def __init__(self):
            print "parent"
            super(Parent, self).__init__()

class Father(Parent):
    def __init__(self):
            print "father"
            super(Father, self).__init__()
            print "D-uh"

class Mother(Parent):
    def __init__(self):
            print "mother"
            super(Mother, self).__init__()
            print "D-oh"

class Child(Father, Mother):
    def __init__(self):
            print "child"
            super(Child, self).__init__()

Child()
################################################

This prints
 child
 father
 mother
 parent
 D-oh
 D-uh

Therefore super is a very intelligent function indeed!


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

Reply via email to