[Python-Dev] One-line abstractmethod function?

Ethan Furman ethan at stoneleaf.us
Fri Dec 6 03:31:16 CET 2013

On 12/05/2013 06:08 PM, Allen Li wrote:
> On Thu, Dec 05, 2013 at 01:33:00PM -0800, Guido van Rossum wrote:
>> Actually if you want to support multiple inheritance of your ABC, your
>> abstract methods *must* be no-ops (or have some kind of default
>> behavior that can always be done last).

Done last or first really depends on what the default behavior is, doesn't it?  Using __new__ as an example, the chain 
of calls for that has the most ancestorish (yeah, I just made that word up ;) method doing the work first, with each 
less-ancestorish method building on to that as the call chain unwinds.

> I must respectfully disagree with this.  If your ABCs aren't meant to be
> in the MRO, then you should be @registering them as virtual classes and
> not inheriting them.

Why would you think they are not meant to be in the MRO?  When dealing with multiple-inheritance, there must be a base 
class that does not try to call super() (object does not work for this) -- what better class to use than the base 
abstract class?

> The trick with Python multiple inheritance and super() (from personal
> experience) is to not think of it as multiple inheritance (a tree with
> cycles), but as building the MRO (linear, the same as single
> inheritance).


More information about the Python-Dev mailing list