This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author gvanrossum
Recipients ecatmur, gvanrossum, lukasz.langa, rhettinger
Date 2013-06-27.16:51:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1372351866.18.0.109453747257.issue18244@psf.upfronthosting.co.za>
In-reply-to
Content
Hm. I interpret "explicit is better than implicit" very differently.  I see a strict priority ordering from better to worse, in cases that would otherwise be ambiguous:

1. explicit base class (ABC or otherwise)

2. ABC explicitly registered

3. ABC implicitly inferred from presence of special method

I'm all for using all the other heuristics and rules you describe: inferred ABCs occur at the level where they are introduced, for example, and if two different ABCs are both inferred at the same level or both registered at the same level, that should be considered ambiguous.  But if one ABC is listed as an explicit base at some level and another is registered or implicit at the same level, the explicit base should just win -- just as if both ABCs were explicitly listed, the one listed first wins.

So the rule should be that registered and inferred bases are only considered after explicit bases at the same level.  (If you want the registered class to be preferred, you should add it as an explicit base instead -- and if you don't own the code, you should respect the choice of its author, or do something using subclassing.)

If it were me, explicitly registered ABCs would also trump inferred ABCs -- after all an inferred ABC is far from obvious to most readers and might even be an accident, and the situation can be rectified by explicit registration.

IOW, I disagree with your claim that "Class C is-a Sized just as well as it is-a Iterable."  C is a Sized *more* than an Iterable because Size is an explicitly listed base class and Iterable is added through registration.  Same if Iterable were inferred.

(Just to be clear, this only applies if the ambiguity occurs at a single level.  ABCs explicitly listed, registered, or inferred at some base class have explicitly lower priority.)
History
Date User Action Args
2013-06-27 16:51:06gvanrossumsetrecipients: + gvanrossum, rhettinger, lukasz.langa, ecatmur
2013-06-27 16:51:06gvanrossumsetmessageid: <1372351866.18.0.109453747257.issue18244@psf.upfronthosting.co.za>
2013-06-27 16:51:06gvanrossumlinkissue18244 messages
2013-06-27 16:51:05gvanrossumcreate