OO Details

Michael Charlton Michael.Charlton at nationwideisp.net
Sat Oct 9 16:07:47 EDT 1999


Dirk Leas <dirkl at home.com> wrote in message
news:37FF842F.BA011E3D at home.com...
> I was looking through the language reference (www.python.org) and was
> unable to find details about how the OO features work. Specifically, I'm
> wondering how ambiguous methods are resolved in multiple inheritance and
> stuff like that.
>
> Where are some good detail references? I thumbed through the Learning
> and Programming O'Reilly books and they didn't seem to cover that level
> of detail (though I didn't exhaustively read them).
>
> TIA,
> D
>


Say we have the following

    class A:

        def  spam(self):
                pass

    class B:

        def spam(self):
                pass


    class C(A,B):

        def eggs(self):
                pass



   then class C will inherit A's definition of the spam method. Python has a
very simple
   algorithm for resolving ambiguous methods in inherited classes, which can
be
    summarised as follows

        depth first, left to right

    so C inherits all (acessable) methods from A then B etc

    I think this is explained in the python tutorial and "Quick Python" by
Ken McDonald.

    Hope this is clear, if not drop us a line

                        Regards

                                Michael Charlton







More information about the Python-list mailing list