February 2006
Intermediate to advanced
648 pages
14h 53m
English
Python 2.1 and earlier versions implemented classes using a different mechanism than what is currently used. However, these old-style or classic classes are still supported for backward compatibility. A classic class is defined whenever a class does not inherit (directly or indirectly) from object. For example:
class A: # A classic class
def __init__(self,x):
self.x = x
class B(A): pass # A classic class--inherits from AAlmost all the basic principles discussed in this chapter apply to classic classes. However, these classes are somewhat more limited in their features. The following list briefly outlines some of the differences.
Classic classes do not define new types. In fact, the type of all instances regardless of class is ...
Read now
Unlock full access