Everything is an object in python - object class and type class

random832 at fastmail.us random832 at fastmail.us
Tue Jun 2 00:13:46 EDT 2015


On Mon, Jun 1, 2015, at 21:15, TheDoctor wrote:
> In Python 2.7 type(type) is type (not object), but isinstance(type,
> object) is true -- so it is ambiguous, even contradictory, in the
> language.

isinstance(type, object) is true because object is the parent class of
type. issubclass(type, object) is also true, and that is why
isinstance(int, object) is true. There is no more contradiction than in
anything else being an instance of its own class, its parent class, that
class's parent class, and ultimately... well, object.

type in object.__subclasses__() is also true.
type.__base__ is object.

I could go on.



More information about the Python-list mailing list