This is a note about classic classes in Python. We can create classes of the old (pre 2.2) kind by using a plain class statement.
A class statement
specifying no bases creates a classic class
Remember that to create a new-style class you must
specify | |
Its type is an object we haven't seen before (in this book). | |
The type of classic
classes is an object called
| |
It looks and smells like just another type object. |
The types.ClassType object is in some ways an
alternative <type 'type'>. Instances of this object (classic classes) are
types themselves. The rules of attribute access are different for
classic classes and new-style classes. The
types.ClassType object exists for backward
compatibility and may not exist in future versions of Python. Other
sections of this book should not be applied to classic classes.
Comment on this book here: discussion page. I appreciate feedback!
That's all, folks!
... pass
...
>>> type(ClassicClass)
<type 'classobj'>
>>> import types
>>> types.ClassType is type(ClassicClass)
True
>>> types.ClassType.__class__
<type 'type'>
>>> types.ClassType.__bases__
(<type 'object'>,)