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.
Example 3.2. Examining classic classes
>>> class ClassicClass:... pass ... >>> type(ClassicClass)
<type 'classobj'> >>> import types >>> types.ClassType is type(ClassicClass)
True >>> types.ClassType.__class__
<type 'type'> >>> types.ClassType.__bases__
(<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'>,)