Arnaud Delobelle a écrit :
rludwinowski <rludwinow...@gmail.com> writes:

class A:
    def __init__(self):
        print("A__init__")

class B:
    def __init__(self):
        print("B__init__")

class C(A, B):
    pass

C()

A__init__
Why __init__ class B will not be automatic executed?

Because it's documented behaviour?  By default, at initialisation, an
instance of C will go up the method resolution order and only execture
the first __init__() method found.

Note to the OP : Python's "methods" are attributes, so the normal attribute lookup rules apply - which is why the lookup stops at the first (in _mro_ order) '__init__' method found.

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

Reply via email to