Recently I stumbled across an article talking about the importance of understanding type and object in Python, so thought of writing a small post on it.
Looking in-depth, one may get the impression that this is more of a chicked-egg problem, but I’ll give an overall view of this.
- An
object
is basically an instance oftype
type
is an instance oftype
itselfobject
is the subclass of all other objects- A
type
is an instance ofobject
itself
So in a way, you have only two objects in Python, types and non-types.
type
can also be called class
from Python >= 2.3Well there you go. It wasn’t confusing now, was it ? :)