In the present scope, this document can be considered as just an appendix to [].
Author
|
Document date
|
The .class map is monotone with respect to inheritance,
i.e. for every classes x, y,
| |
The inheritance ≤
is a partial order between objects.
In addition,
| |
The set {r, c} forms the least substructure.
More specifically,
| |
For every terminal object x,
| |
The .class map
forms a tree on objects called the instance tree.
In addition,
|
Proposition:
Notation | Terminology | Python expression |
r | inheritance root | object |
c | metaclass root | type |
x is a class | isinstance(x,type) |
|
x is a metaclass | issubclass(x,type) |
|
x.class | the class of x | x.__class__ |
x ≤ y | x is a descendant of y | issubclass(x,y) |
x.class ≤ y | x is an instance of y | isinstance(x,y) |
Note:
As of version 3.2, Python allows structures that do NOT satisfy
condition
class M(type): def mro(x): return [] class X(metaclass=M): pass print (issubclass(X,X)) # False print (issubclass(X,object)) # False
For classes x, y, we write
The structure is subject to the following conditions:
The inheritance ≤ is obtained from ._mro by
| |
The inheritance ≤ is also obtained from ._bas as the reflexive transitive closure of ⋖. | |
For every class x,
|
Learning Python, O'Reilly 2009 | ,|
Object Membership: The core structure of object-oriented programming, 2012–2014, http://www.atalon.cz/om/object-membership/oop/ | ,|
Python's attribute lookup order, 2011, http://utcc.utoronto.ca/~cks/space/blog/python/AttributeLookupOrder | ,
August | 24 | 2012 | The initial release. |
January | 22 | 2013 |
Conditions |