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

random832 at fastmail.us random832 at fastmail.us
Tue Jun 2 00:08:51 EDT 2015


On Mon, Jun 1, 2015, at 20:24, TheDoctor wrote:
> A type is not an object in the same way an instantiated type is an object
> -- anymore than a blueprint for a building is the building itself.

What is an object?

It's something you can call str or repr on. It's something you can
lookup attributes from its internal dictionary and call methods on. It's
something you can compare whether it's == to something else. It's
something you can pass as a parameter to a function

In many languages, you can't do any of these things (or their
equivalents for those languages) to a type. In others, you have to get a
special "class object" that isn't _really_ the same thing as the type
itself, via some special syntax like typeof(Foo) or Foo.class, and can
only work with it through magic methods in a certain module.

In python, you can. Why is this bad or confusing?



More information about the Python-list mailing list