There are two kinds of objects in Python:
Type objects - can create instances, can be subclassed.
Non-type objects - cannot create instances, cannot be subclassed.
<type 'object'>are two primitive objects of the system.
objectname.__class__exists for every object and points the type of the object.
objectname.__bases__exists for every type object and points the superclasses of the object. It is empty only for
To create a new object using subclassing, we use the
classstatement and specify the bases (and, optionally, the type) of the new object. This always creates a type object.
To create a new object using instantiation, we use the call operator (
()) on the type object we want to use. This may create a type or a non-type object, depending on which type object was used.
Some non-type objects can be created using special Python syntax. For example,
[1, 2, 3]creates an instance of
Internally, Python always uses a type object to create a new object. The new object created is an instance of the type object used. Python determines the type object from a
classstatement by looking at the bases specified, and finding their types.
issubclass(A,B)(testing for superclass-subclass relationship) returns
issubclass(Z,B)is true for any
isinstance(A,B)(testing for type-instance relationship) returns
Squasher is really a python. (Okay, that wasn't mentioned before, but now you know.)