[docs] [issue31283] Inconsistent behaviours with explicit and implicit inheritance from object

R. David Murray report at bugs.python.org
Sat Aug 26 11:30:00 EDT 2017

R. David Murray added the comment:

I see I didn't specifically address your counter argument ("that would obviously be absurd").  Having thought it it some more, your are right, there *is* a difference between the examples you think it would be absurd to disclaim and your example here.  In python, an entity is identified by an id (which is a memory address in CPython, but that's an implementation detail).  A name is just a convenience label used to refer to that id.  When you rebind a name, you change what id it points to, but any other piece of python that is already using the original id is not affected.  But anything using an indirect reference through another object (such as builtins) *will* see the change.

Your argument, then, is that it is not documented that 'class x:' is using a direct reference to object rather than an indirect reference.  Our argument is that this is obviously the way Python works (the interpreter itself refers directly to the fundamental entities such as the base of the exception hierarchy and object).

The number of places that would need to be changed to make this explicit is much smaller than I was thinking when I closed the issue, but I'm still not convinced it is something that needs to be explicitly documented.  It is just part of the way Python works at a fundamental level, and because it is a *statement* that does not refer to a variable, it is intuitive that it is going to reference the original object, not whatever builtins.object is referring to.

We do say that explicit is better than implicit, but in this case we're talking about a fundamental part of the language, and the specification of how this works probably belongs in some overview section on statements.  On the other hand, are there any examples *other* than class and except where this distinction matters?

resolution: not a bug -> 
stage: resolved -> 
status: closed -> open

Python tracker <report at bugs.python.org>

More information about the docs mailing list