Once upon a time, Python had both types and classes. Types were built-in objects defined in C; classes were what you built when using a class
statement. The two were named differently because you couldn't mix these; classes could not extend types.
This difference was artificial, a limitation in the language implementation. Starting with Python 2.2, the developers of Python have slowly moved towards unifying the two concepts, with the difference all but gone in Python 3. Built-in types are now also labelled classes, and you can extend them at will.
Your book is trying to explain a difference that isn't present in Python anymore. Even in Python 2 the difference is only there in name, since type(2)
shows the word 'type' is still used there:
>>> type(2)
<type 'int'>
but you can subclass int
just like any other class.
(Python 2 does still have old-style classes, those that don't inherit from object
; these are a remnant of the old system from before the unification.)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…