The Python Standard LibraryΒΆ
While The Python Language Reference describes the exact syntax and semantics of the Python language, this library reference manual describes the standard library that is distributed with Python. It also describes some of the optional components that are commonly included in Python distributions.
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.
- 1. Introduction
- 2. Built-in Functions
- 3. Built-in Constants
- 4. Built-in Types
- 4.1. Truth Value Testing
- 4.2. Boolean Operations β
and,or,not - 4.3. Comparisons
- 4.4. Numeric Types β
int,float,complex - 4.5. Iterator Types
- 4.6. Sequence Types β
list,tuple,range - 4.7. Text Sequence Type β
str - 4.8. Binary Sequence Types β
bytes,bytearray,memoryview - 4.9. Set Types β
set,frozenset - 4.10. Mapping Types β
dict - 4.11. Context Manager Types
- 4.12. Other Built-in Types
- 4.13. Special Attributes
- 5. Built-in Exceptions
- 6. Text Processing Services
- 6.1.
stringβ Common string operations - 6.2.
reβ Regular expression operations - 6.3.
difflibβ Helpers for computing deltas - 6.4.
textwrapβ Text wrapping and filling - 6.5.
unicodedataβ Unicode Database - 6.6.
stringprepβ Internet String Preparation - 6.7.
readlineβ GNU readline interface - 6.8.
rlcompleterβ Completion function for GNU readline
- 6.1.
- 7. Binary Data Services
- 8. Data Types
- 8.1.
datetimeβ Basic date and time types - 8.2.
calendarβ General calendar-related functions - 8.3.
collectionsβ Container datatypes - 8.4.
collections.abcβ Abstract Base Classes for Containers - 8.5.
heapqβ Heap queue algorithm - 8.6.
bisectβ Array bisection algorithm - 8.7.
arrayβ Efficient arrays of numeric values - 8.8.
weakrefβ Weak references - 8.9.
typesβ Dynamic type creation and names for built-in types - 8.10.
copyβ Shallow and deep copy operations - 8.11.
pprintβ Data pretty printer - 8.12.
reprlibβ Alternaterepr()implementation - 8.13.
enumβ Support for enumerations
- 8.1.
- 9. Numeric and Mathematical Modules
- 9.1.
numbersβ Numeric abstract base classes - 9.2.
mathβ Mathematical functions - 9.3.
cmathβ Mathematical functions for complex numbers - 9.4.
decimalβ Decimal fixed point and floating point arithmetic - 9.5.
fractionsβ Rational numbers - 9.6.
randomβ Generate pseudo-random numbers - 9.7.
statisticsβ Mathematical statistics functions
- 9.1.
- 10. Functional Programming Modules
- 11. File and Directory Access
- 11.1.
pathlibβ Object-oriented filesystem paths - 11.2.
os.pathβ Common pathname manipulations - 11.3.
fileinputβ Iterate over lines from multiple input streams - 11.4.
statβ Interpretingstat()results - 11.5.
filecmpβ File and Directory Comparisons - 11.6.
tempfileβ Generate temporary files and directories - 11.7.
globβ Unix style pathname pattern expansion - 11.8.
fnmatchβ Unix filename pattern matching - 11.9.
linecacheβ Random access to text lines - 11.10.
shutilβ High-level file operations - 11.11.
macpathβ Mac OS 9 path manipulation functions
- 11.1.
- 12. Data Persistence
- 12.1.
pickleβ Python object serialization - 12.2.
copyregβ Registerpicklesupport functions - 12.3.
shelveβ Python object persistence - 12.4.
marshalβ Internal Python object serialization - 12.5.
dbmβ Interfaces to Unix βdatabasesβ - 12.6.
sqlite3β DB-API 2.0 interface for SQLite databases
- 12.1.
- 13. Data Compression and Archiving
- 14. File Formats
- 15. Cryptographic Services
- 16. Generic Operating System Services
- 16.1.
osβ Miscellaneous operating system interfaces - 16.2.
ioβ Core tools for working with streams - 16.3.
timeβ Time access and conversions - 16.4.
argparseβ Parser for command-line options, arguments and sub-commands - 16.5.
getoptβ C-style parser for command line options - 16.6.
loggingβ Logging facility for Python - 16.7.
logging.configβ Logging configuration - 16.8.
logging.handlersβ Logging handlers - 16.9.
getpassβ Portable password input - 16.10.
cursesβ Terminal handling for character-cell displays - 16.11.
curses.textpadβ Text input widget for curses programs - 16.12.
curses.asciiβ Utilities for ASCII characters - 16.13.
curses.panelβ A panel stack extension for curses - 16.14.
platformβ Access to underlying platformβs identifying data - 16.15.
errnoβ Standard errno system symbols - 16.16.
ctypesβ A foreign function library for Python
- 16.1.
- 17. Concurrent Execution
- 17.1.
threadingβ Thread-based parallelism - 17.2.
multiprocessingβ Process-based parallelism - 17.3. The
concurrentpackage - 17.4.
concurrent.futuresβ Launching parallel tasks - 17.5.
subprocessβ Subprocess management - 17.6.
schedβ Event scheduler - 17.7.
queueβ A synchronized queue class - 17.8.
dummy_threadingβ Drop-in replacement for thethreadingmodule - 17.9.
_threadβ Low-level threading API - 17.10.
_dummy_threadβ Drop-in replacement for the_threadmodule
- 17.1.
- 18. Interprocess Communication and Networking
- 18.1.
socketβ Low-level networking interface - 18.2.
sslβ TLS/SSL wrapper for socket objects - 18.3.
selectβ Waiting for I/O completion - 18.4.
selectorsβ High-level I/O multiplexing - 18.5.
asyncioβ Asynchronous I/O, event loop, coroutines and tasks - 18.6.
asyncoreβ Asynchronous socket handler - 18.7.
asynchatβ Asynchronous socket command/response handler - 18.8.
signalβ Set handlers for asynchronous events - 18.9.
mmapβ Memory-mapped file support
- 18.1.
- 19. Internet Data Handling
- 19.1.
emailβ An email and MIME handling package - 19.2.
jsonβ JSON encoder and decoder - 19.3.
mailcapβ Mailcap file handling - 19.4.
mailboxβ Manipulate mailboxes in various formats - 19.5.
mimetypesβ Map filenames to MIME types - 19.6.
base64β Base16, Base32, Base64, Base85 Data Encodings - 19.7.
binhexβ Encode and decode binhex4 files - 19.8.
binasciiβ Convert between binary and ASCII - 19.9.
quopriβ Encode and decode MIME quoted-printable data - 19.10.
uuβ Encode and decode uuencode files
- 19.1.
- 20. Structured Markup Processing Tools
- 20.1.
htmlβ HyperText Markup Language support - 20.2.
html.parserβ Simple HTML and XHTML parser - 20.3.
html.entitiesβ Definitions of HTML general entities - 20.4. XML Processing Modules
- 20.5.
xml.etree.ElementTreeβ The ElementTree XML API - 20.6.
xml.domβ The Document Object Model API - 20.7.
xml.dom.minidomβ Minimal DOM implementation - 20.8.
xml.dom.pulldomβ Support for building partial DOM trees - 20.9.
xml.saxβ Support for SAX2 parsers - 20.10.
xml.sax.handlerβ Base classes for SAX handlers - 20.11.
xml.sax.saxutilsβ SAX Utilities - 20.12.
xml.sax.xmlreaderβ Interface for XML parsers - 20.13.
xml.parsers.expatβ Fast XML parsing using Expat
- 20.1.
- 21. Internet Protocols and Support
- 21.1.
webbrowserβ Convenient Web-browser controller - 21.2.
cgiβ Common Gateway Interface support - 21.3.
cgitbβ Traceback manager for CGI scripts - 21.4.
wsgirefβ WSGI Utilities and Reference Implementation - 21.5.
urllibβ URL handling modules - 21.6.
urllib.requestβ Extensible library for opening URLs - 21.7.
urllib.responseβ Response classes used by urllib - 21.8.
urllib.parseβ Parse URLs into components - 21.9.
urllib.errorβ Exception classes raised by urllib.request - 21.10.
urllib.robotparserβ Parser for robots.txt - 21.11.
httpβ HTTP modules - 21.12.
http.clientβ HTTP protocol client - 21.13.
ftplibβ FTP protocol client - 21.14.
poplibβ POP3 protocol client - 21.15.
imaplibβ IMAP4 protocol client - 21.16.
nntplibβ NNTP protocol client - 21.17.
smtplibβ SMTP protocol client - 21.18.
smtpdβ SMTP Server - 21.19.
telnetlibβ Telnet client - 21.20.
uuidβ UUID objects according to RFC 4122 - 21.21.
socketserverβ A framework for network servers - 21.22.
http.serverβ HTTP servers - 21.23.
http.cookiesβ HTTP state management - 21.24.
http.cookiejarβ Cookie handling for HTTP clients - 21.25.
xmlrpcβ XMLRPC server and client modules - 21.26.
xmlrpc.clientβ XML-RPC client access - 21.27.
xmlrpc.serverβ Basic XML-RPC servers - 21.28.
ipaddressβ IPv4/IPv6 manipulation library
- 21.1.
- 22. Multimedia Services
- 22.1.
audioopβ Manipulate raw audio data - 22.2.
aifcβ Read and write AIFF and AIFC files - 22.3.
sunauβ Read and write Sun AU files - 22.4.
waveβ Read and write WAV files - 22.5.
chunkβ Read IFF chunked data - 22.6.
colorsysβ Conversions between color systems - 22.7.
imghdrβ Determine the type of an image - 22.8.
sndhdrβ Determine type of sound file - 22.9.
ossaudiodevβ Access to OSS-compatible audio devices
- 22.1.
- 23. Internationalization
- 24. Program Frameworks
- 25. Graphical User Interfaces with Tk
- 26. Development Tools
- 26.1.
typingβ Support for type hints - 26.2.
pydocβ Documentation generator and online help system - 26.3.
doctestβ Test interactive Python examples - 26.4.
unittestβ Unit testing framework - 26.5.
unittest.mockβ mock object library - 26.6.
unittest.mockβ getting started - 26.7. 2to3 - Automated Python 2 to 3 code translation
- 26.8.
testβ Regression tests package for Python - 26.9.
test.supportβ Utilities for the Python test suite
- 26.1.
- 27. Debugging and Profiling
- 27.1.
bdbβ Debugger framework - 27.2.
faulthandlerβ Dump the Python traceback - 27.3.
pdbβ The Python Debugger - 27.4. The Python Profilers
- 27.5.
timeitβ Measure execution time of small code snippets - 27.6.
traceβ Trace or track Python statement execution - 27.7.
tracemallocβ Trace memory allocations
- 27.1.
- 28. Software Packaging and Distribution
- 29. Python Runtime Services
- 29.1.
sysβ System-specific parameters and functions - 29.2.
sysconfigβ Provide access to Pythonβs configuration information - 29.3.
builtinsβ Built-in objects - 29.4.
__main__β Top-level script environment - 29.5.
warningsβ Warning control - 29.6.
contextlibβ Utilities forwith-statement contexts - 29.7.
abcβ Abstract Base Classes - 29.8.
atexitβ Exit handlers - 29.9.
tracebackβ Print or retrieve a stack traceback - 29.10.
__future__β Future statement definitions - 29.11.
gcβ Garbage Collector interface - 29.12.
inspectβ Inspect live objects - 29.13.
siteβ Site-specific configuration hook - 29.14.
fpectlβ Floating point exception control
- 29.1.
- 30. Custom Python Interpreters
- 31. Importing Modules
- 32. Python Language Services
- 32.1.
parserβ Access Python parse trees - 32.2.
astβ Abstract Syntax Trees - 32.3.
symtableβ Access to the compilerβs symbol tables - 32.4.
symbolβ Constants used with Python parse trees - 32.5.
tokenβ Constants used with Python parse trees - 32.6.
keywordβ Testing for Python keywords - 32.7.
tokenizeβ Tokenizer for Python source - 32.8.
tabnannyβ Detection of ambiguous indentation - 32.9.
pyclbrβ Python class browser support - 32.10.
py_compileβ Compile Python source files - 32.11.
compileallβ Byte-compile Python libraries - 32.12.
disβ Disassembler for Python bytecode - 32.13.
pickletoolsβ Tools for pickle developers
- 32.1.
- 33. Miscellaneous Services
- 34. MS Windows Specific Services
- 35. Unix Specific Services
- 35.1.
posixβ The most common POSIX system calls - 35.2.
pwdβ The password database - 35.3.
spwdβ The shadow password database - 35.4.
grpβ The group database - 35.5.
cryptβ Function to check Unix passwords - 35.6.
termiosβ POSIX style tty control - 35.7.
ttyβ Terminal control functions - 35.8.
ptyβ Pseudo-terminal utilities - 35.9.
fcntlβ Thefcntlandioctlsystem calls - 35.10.
pipesβ Interface to shell pipelines - 35.11.
resourceβ Resource usage information - 35.12.
nisβ Interface to Sunβs NIS (Yellow Pages) - 35.13.
syslogβ Unix syslog library routines
- 35.1.
- 36. Superseded Modules
- 37. Undocumented Modules
