user6774416 user6774416 - 14 days ago 5
Python Question

Custom classes with empty __bases__ attribute

In the section on Custom Classes of The Python Language Reference it is stated that:


Special attributes:
__name__
is the class name;
__module__
is the module name in which the class was defined;
__dict__
is the dictionary containing the class’s namespace;
__bases__
is a tuple (possibly empty or a singleton) containing the base classes, in the order of their occurrence in the base class list;
__doc__
is the class’s documentation string, or
None
if undefined.


So,
__bases__
for a custom class can "possibly be empty"? How can that be achieved if everything implicitly inherits from
object
in Python
3
?

The only class with an empty
__bases__
is
object
itself:

>>> object.__bases__
()


Am I missing something?

wim wim
Answer

The line has been there since before Python 3 was released. Here's the 2007 commit. When the object model was revamped to get rid of old-style classes, it looks like that information in the docs slipped through review and is likely just misinformation now.

May I suggest you raise a documentation issue to clear up whether it is incorrect/outdated.