The Python Standard Library - Python 3.7.4 Documentation
The Python Standard Library - Python 3.7.4 Documentation
4 documentation
Python’s standard library is very extensive, offering a wide range of facilities as indicated by the
long table of contents listed below. The library contains built-in modules (written in C) that provide
access to system functionality such as file I/O that would otherwise be inaccessible to Python
programmers, as well as modules written in Python that provide standardized solutions for many
problems that occur in everyday programming. Some of these modules are explicitly designed to
encourage and enhance the portability of Python programs by abstracting away platform-
specifics into platform-neutral APIs.
The Python installers for the Windows platform usually include the entire standard library and
often also include many additional components. For Unix-like operating systems Python is
normally provided as a collection of packages, so it may be necessary to use the packaging tools
provided with the operating system to obtain some or all of the optional components.
In addition to the standard library, there is a growing collection of several thousand components
(from individual programs and modules to packages and entire application development
frameworks), available from the Python Package Index.
Introduction
Notes on availability
Built-in Functions
Built-in Constants
Constants added by the site module
Built-in Types
Truth Value Testing
Boolean Operations — and , or , not
Comparisons
Numeric Types — int , float , complex
Iterator Types
Sequence Types — list , tuple , range
Text Sequence Type — str
Binary Sequence Types — bytes , bytearray , memoryview
Set Types — set , frozenset
Mapping Types — dict
Context Manager Types
Other Built-in Types
Special Attributes
Built-in Exceptions
Base classes
Concrete exceptions
https://docs.python.org/3/library/ 1/7
8/15/2019 The Python Standard Library — Python 3.7.4 documentation
Warnings
Exception hierarchy
Text Processing Services
string — Common string operations
re — Regular expression operations
difflib — Helpers for computing deltas
textwrap — Text wrapping and filling
unicodedata — Unicode Database
stringprep — Internet String Preparation
readline — GNU readline interface
rlcompleter — Completion function for GNU readline
Binary Data Services
struct — Interpret bytes as packed binary data
codecs — Codec registry and base classes
Data Types
datetime — Basic date and time types
calendar — General calendar-related functions
collections — Container datatypes
collections.abc — Abstract Base Classes for Containers
heapq — Heap queue algorithm
bisect — Array bisection algorithm
array — Efficient arrays of numeric values
weakref — Weak references
types — Dynamic type creation and names for built-in types
copy — Shallow and deep copy operations
pprint — Data pretty printer
reprlib — Alternate repr() implementation
enum — Support for enumerations
Numeric and Mathematical Modules
numbers — Numeric abstract base classes
math — Mathematical functions
cmath — Mathematical functions for complex numbers
decimal — Decimal fixed point and floating point arithmetic
fractions — Rational numbers
random — Generate pseudo-random numbers
statistics — Mathematical statistics functions
Functional Programming Modules
itertools — Functions creating iterators for efficient looping
functools — Higher-order functions and operations on callable objects
operator — Standard operators as functions
File and Directory Access
pathlib — Object-oriented filesystem paths
os.path — Common pathname manipulations
fileinput — Iterate over lines from multiple input streams
stat — Interpreting stat() results
filecmp — File and Directory Comparisons
tempfile — Generate temporary files and directories
glob — Unix style pathname pattern expansion
fnmatch — Unix filename pattern matching
https://docs.python.org/3/library/ 2/7
8/15/2019 The Python Standard Library — Python 3.7.4 documentation
Development Tools
typing — Support for type hints
pydoc — Documentation generator and online help system
doctest — Test interactive Python examples
unittest — Unit testing framework
unittest.mock — mock object library
unittest.mock — getting started
2to3 - Automated Python 2 to 3 code translation
test — Regression tests package for Python
test.support — Utilities for the Python test suite
test.support.script_helper — Utilities for the Python execution tests
Debugging and Profiling
bdb — Debugger framework
faulthandler — Dump the Python traceback
pdb — The Python Debugger
The Python Profilers
timeit — Measure execution time of small code snippets
trace — Trace or track Python statement execution
tracemalloc — Trace memory allocations
Software Packaging and Distribution
distutils — Building and installing Python modules
ensurepip — Bootstrapping the pip installer
venv — Creation of virtual environments
zipapp — Manage executable Python zip archives
Python Runtime Services
sys — System-specific parameters and functions
sysconfig — Provide access to Python’s configuration information
builtins — Built-in objects
__main__ — Top-level script environment
warnings — Warning control
dataclasses — Data Classes
contextlib — Utilities for with -statement contexts
abc — Abstract Base Classes
atexit — Exit handlers
traceback — Print or retrieve a stack traceback
__future__ — Future statement definitions
gc — Garbage Collector interface
inspect — Inspect live objects
site — Site-specific configuration hook
Custom Python Interpreters
code — Interpreter base classes
codeop — Compile Python code
Importing Modules
zipimport — Import modules from Zip archives
pkgutil — Package extension utility
modulefinder — Find modules used by a script
runpy — Locating and executing Python modules
importlib — The implementation of import
Python Language Services
https://docs.python.org/3/library/ 6/7
8/15/2019 The Python Standard Library — Python 3.7.4 documentation
https://docs.python.org/3/library/ 7/7