[Python-Dev] Clarification on MRO when inheriting from builtin type.

Chris Angelico rosuav at gmail.com
Mon Apr 28 05:33:58 CEST 2014


On Mon, Apr 28, 2014 at 1:25 PM, Paul Sokolovsky <pmiscml at gmail.com> wrote:
>
> Thanks for quick response! I see that list.__repr__ exists, and test
> using it works "as expected". Hopefully, such stuff can be treated as
> implementation-specific details...

The language defines method lookups and the MRO and such, and then the
class chooses what to define. If your classes aren't specifically
designed with inheritance in mind, multiple inheritance will always
get messy (no matter what language you're in!); even single
inheritance can get messy very quickly if the classes aren't designed
to coexist (there's no safe way to refactor a superclass method
without knowing what subclasses might be overriding).

ChrisA


More information about the Python-Dev mailing list