05 Built-in Types¶
The following sections describe the standard types that are built into the interpreter.
Note
Historically (until release 2.2), Python’s built-in types have differed from user-defined types because it was not possible to use the built-in types as the basis for object-oriented inheritance. This limitation no longer exists.
The principal built-in types are numerics, sequences, mappings, files, classes, instances and exceptions.
Some operations are supported by several object types; in particular,
practically all objects can be compared, tested for truth value, and converted
to a string (with the repr() function or the slightly different
str() function). The latter function is implicitly used when an object is
written by the print() function.
Contents¶
- 1. Truth Value Testing
- 2. Boolean Operations —
and,or,not - 3. Comparisons
- 4. Numeric Types —
int,float,long,complex - 5. Iterator Types
- 6. Sequence Types —
str,unicode,list,tuple,bytearray,buffer,xrange - 7. Set Types —
set,frozenset - 8. Mapping Types —
dict - 9. File Objects
- 10. memoryview type
- 11. Context Manager Types
- 12. Other Built-in Types
- 13. Special Attributes