Chapter 8. Core Built-ins
The term built-in has more than one meaning in
Python. In most contexts, a built-in is any object directly
accessible to a Python program without an import
statement. Chapter 7 showed the mechanism that
Python uses to allow this direct access. Built-in types in Python
include numbers, sequences, dictionaries, functions (covered in Chapter 4), classes (covered in Chapter 5), the standard exception classes (covered in
Chapter 6), and modules (covered in Chapter 7). The built-in file
object
is covered in Chapter 10, and other built-in types
covered in Chapter 13 are intrinsic to
Python’s internal operation. This chapter provides
additional coverage of the core built-in types, and it also covers
the built-in functions available in module __builtin__
.
As I mentioned in Chapter 7, some modules are
called built-in because they are an integral part of the Python
standard library, even though it takes an import
statement to access them. Built-in modules are distinct from
separate, optional add-on modules, also called Python
extensions. This chapter documents the following
core built-in modules: sys
,
getopt
, copy
,
bisect
, UserList
,
UserDict
, and UserString
. Chapter 9 covers some string-related core built-in
modules, while Parts III and IV of the book cover many other useful
built-in modules.
Built-in Types
This
section documents Python’s core built-in types, like
int
, float
, and
dict
. Note that prior to Python 2.2, these names referred to factory functions for creating ...
Get Python in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.