According to the doc, object is all new-style classes’ base class.
And AFAIK, the so-called new-style classes are just ones which can acquire some new fetures by inheriting object, right?
I thought object inherit type or use type as its __metaclass__, but object.__bases__ gives me nothing, so where dose this object come from, and what’s relationship bewteen it and type?
Indeed, the type (i.e., metaclass) of
object, a class, istype:And since
objectis the base class, it has no parents of its own, as you’d expect:objectdoesn’t have a__metaclass__attribute because it doesn’t need one: it uses the default metaclass,type.Now it’s a little confusing because
typeis in fact a subclass ofobject, which boggles the mind (how cantypebe derived fromobjectwhen you needtypeto constructobject?) but this is solved by a little hard-coding at the C level in the Python interpreter.All this applies only to new-style classes, that is, those derived from
object. In Python 3, all classes are new-style, so this applies globally in Python 3.