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.
Pythons 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.
stringCommon string operations - 6.2.
reRegular expression operations - 6.3.
difflibHelpers for computing deltas - 6.4.
textwrapText wrapping and filling - 6.5.
unicodedataUnicode Database - 6.6.
stringprepInternet String Preparation - 6.7.
readlineGNU readline interface - 6.8.
rlcompleterCompletion function for GNU readline
- 6.1.
- 7. Binary Data Services
- 8. Data Types
- 8.1.
datetimeBasic date and time types - 8.2.
calendarGeneral calendar-related functions - 8.3.
collectionsContainer datatypes - 8.4.
collections.abcAbstract Base Classes for Containers - 8.5.
heapqHeap queue algorithm - 8.6.
bisectArray bisection algorithm - 8.7.
arrayEfficient arrays of numeric values - 8.8.
weakrefWeak references - 8.9.
typesDynamic type creation and names for built-in types - 8.10.
copyShallow and deep copy operations - 8.11.
pprintData pretty printer - 8.12.
reprlibAlternaterepr()implementation - 8.13.
enumSupport for enumerations
- 8.1.
- 9. Numeric and Mathematical Modules
- 9.1.
numbersNumeric abstract base classes - 9.2.
mathMathematical functions - 9.3.
cmathMathematical functions for complex numbers - 9.4.
decimalDecimal fixed point and floating point arithmetic - 9.5.
fractionsRational numbers - 9.6.
randomGenerate pseudo-random numbers - 9.7.
statisticsMathematical statistics functions
- 9.1.
- 10. Functional Programming Modules
- 11. File and Directory Access
- 11.1.
pathlibObject-oriented filesystem paths - 11.2.
os.pathCommon pathname manipulations - 11.3.
fileinputIterate over lines from multiple input streams - 11.4.
statInterpretingstat()results - 11.5.
filecmpFile and Directory Comparisons - 11.6.
tempfileGenerate temporary files and directories - 11.7.
globUnix style pathname pattern expansion - 11.8.
fnmatchUnix filename pattern matching - 11.9.
linecacheRandom access to text lines - 11.10.
shutilHigh-level file operations - 11.11.
macpathMac OS 9 path manipulation functions
- 11.1.
- 12. Data Persistence
- 13. Data Compression and Archiving
- 14. File Formats
- 15. Cryptographic Services
- 16. Generic Operating System Services
- 16.1.
osMiscellaneous operating system interfaces - 16.2.
ioCore tools for working with streams - 16.3.
timeTime access and conversions - 16.4.
argparseParser for command-line options, arguments and sub-commands - 16.5.
getoptC-style parser for command line options - 16.6.
loggingLogging facility for Python - 16.7.
logging.configLogging configuration - 16.8.
logging.handlersLogging handlers - 16.9.
getpassPortable password input - 16.10.
cursesTerminal handling for character-cell displays - 16.11.
curses.textpadText input widget for curses programs - 16.12.
curses.asciiUtilities for ASCII characters - 16.13.
curses.panelA panel stack extension for curses - 16.14.
platformAccess to underlying platforms identifying data - 16.15.
errnoStandard errno system symbols - 16.16.
ctypesA foreign function library for Python
- 16.1.
- 17. Concurrent Execution
- 17.1.
threadingThread-based parallelism - 17.2.
multiprocessingProcess-based parallelism - 17.3. The
concurrentpackage - 17.4.
concurrent.futuresLaunching parallel tasks - 17.5.
subprocessSubprocess management - 17.6.
schedEvent scheduler - 17.7.
queueA synchronized queue class - 17.8.
dummy_threadingDrop-in replacement for thethreadingmodule - 17.9.
_threadLow-level threading API - 17.10.
_dummy_threadDrop-in replacement for the_threadmodule
- 17.1.
- 18. Interprocess Communication and Networking
- 18.1.
socketLow-level networking interface - 18.2.
sslTLS/SSL wrapper for socket objects - 18.3.
selectWaiting for I/O completion - 18.4.
selectorsHigh-level I/O multiplexing - 18.5.
asyncioAsynchronous I/O, event loop, coroutines and tasks - 18.6.
asyncoreAsynchronous socket handler - 18.7.
asynchatAsynchronous socket command/response handler - 18.8.
signalSet handlers for asynchronous events - 18.9.
mmapMemory-mapped file support
- 18.1.
- 19. Internet Data Handling
- 19.1.
emailAn email and MIME handling package - 19.2.
jsonJSON encoder and decoder - 19.3.
mailcapMailcap file handling - 19.4.
mailboxManipulate mailboxes in various formats - 19.5.
mimetypesMap filenames to MIME types - 19.6.
base64Base16, Base32, Base64, Base85 Data Encodings - 19.7.
binhexEncode and decode binhex4 files - 19.8.
binasciiConvert between binary and ASCII - 19.9.
quopriEncode and decode MIME quoted-printable data - 19.10.
uuEncode and decode uuencode files
- 19.1.
- 20. Structured Markup Processing Tools
- 20.1.
htmlHyperText Markup Language support - 20.2.
html.parserSimple HTML and XHTML parser - 20.3.
html.entitiesDefinitions of HTML general entities - 20.4. XML Processing Modules
- 20.5.
xml.etree.ElementTreeThe ElementTree XML API - 20.6.
xml.domThe Document Object Model API - 20.7.
xml.dom.minidomMinimal DOM implementation - 20.8.
xml.dom.pulldomSupport for building partial DOM trees - 20.9.
xml.saxSupport for SAX2 parsers - 20.10.
xml.sax.handlerBase classes for SAX handlers - 20.11.
xml.sax.saxutilsSAX Utilities - 20.12.
xml.sax.xmlreaderInterface for XML parsers - 20.13.
xml.parsers.expatFast XML parsing using Expat
- 20.1.
- 21. Internet Protocols and Support
- 21.1.
webbrowserConvenient Web-browser controller - 21.2.
cgiCommon Gateway Interface support - 21.3.
cgitbTraceback manager for CGI scripts - 21.4.
wsgirefWSGI Utilities and Reference Implementation - 21.5.
urllibURL handling modules - 21.6.
urllib.requestExtensible library for opening URLs - 21.7.
urllib.responseResponse classes used by urllib - 21.8.
urllib.parseParse URLs into components - 21.9.
urllib.errorException classes raised by urllib.request - 21.10.
urllib.robotparserParser for robots.txt - 21.11.
httpHTTP modules - 21.12.
http.clientHTTP protocol client - 21.13.
ftplibFTP protocol client - 21.14.
poplibPOP3 protocol client - 21.15.
imaplibIMAP4 protocol client - 21.16.
nntplibNNTP protocol client - 21.17.
smtplibSMTP protocol client - 21.18.
smtpdSMTP Server - 21.19.
telnetlibTelnet client - 21.20.
uuidUUID objects according to RFC 4122 - 21.21.
socketserverA framework for network servers - 21.22.
http.serverHTTP servers - 21.23.
http.cookiesHTTP state management - 21.24.
http.cookiejarCookie handling for HTTP clients - 21.25.
xmlrpcXMLRPC server and client modules - 21.26.
xmlrpc.clientXML-RPC client access - 21.27.
xmlrpc.serverBasic XML-RPC servers - 21.28.
ipaddressIPv4/IPv6 manipulation library
- 21.1.
- 22. Multimedia Services
- 22.1.
audioopManipulate raw audio data - 22.2.
aifcRead and write AIFF and AIFC files - 22.3.
sunauRead and write Sun AU files - 22.4.
waveRead and write WAV files - 22.5.
chunkRead IFF chunked data - 22.6.
colorsysConversions between color systems - 22.7.
imghdrDetermine the type of an image - 22.8.
sndhdrDetermine type of sound file - 22.9.
ossaudiodevAccess to OSS-compatible audio devices
- 22.1.
- 23. Internationalization
- 24. Program Frameworks
- 25. Graphical User Interfaces with Tk
- 26. Development Tools
- 26.1.
typingSupport for type hints - 26.2.
pydocDocumentation generator and online help system - 26.3.
doctestTest interactive Python examples - 26.4.
unittestUnit testing framework - 26.5.
unittest.mockmock object library - 26.6.
unittest.mockgetting started - 26.7. 2to3 - Automated Python 2 to 3 code translation
- 26.8.
testRegression tests package for Python - 26.9.
test.supportUtilities for the Python test suite
- 26.1.
- 27. Debugging and Profiling
- 28. Software Packaging and Distribution
- 29. Python Runtime Services
- 29.1.
sysSystem-specific parameters and functions - 29.2.
sysconfigProvide access to Pythons configuration information - 29.3.
builtinsBuilt-in objects - 29.4.
__main__Top-level script environment - 29.5.
warningsWarning control - 29.6.
contextlibUtilities forwith-statement contexts - 29.7.
abcAbstract Base Classes - 29.8.
atexitExit handlers - 29.9.
tracebackPrint or retrieve a stack traceback - 29.10.
__future__Future statement definitions - 29.11.
gcGarbage Collector interface - 29.12.
inspectInspect live objects - 29.13.
siteSite-specific configuration hook - 29.14.
fpectlFloating point exception control
- 29.1.
- 30. Custom Python Interpreters
- 31. Importing Modules
- 32. Python Language Services
- 32.1.
parserAccess Python parse trees - 32.2.
astAbstract Syntax Trees - 32.3.
symtableAccess to the compilers symbol tables - 32.4.
symbolConstants used with Python parse trees - 32.5.
tokenConstants used with Python parse trees - 32.6.
keywordTesting for Python keywords - 32.7.
tokenizeTokenizer for Python source - 32.8.
tabnannyDetection of ambiguous indentation - 32.9.
pyclbrPython class browser support - 32.10.
py_compileCompile Python source files - 32.11.
compileallByte-compile Python libraries - 32.12.
disDisassembler for Python bytecode - 32.13.
pickletoolsTools for pickle developers
- 32.1.
- 33. Miscellaneous Services
- 34. MS Windows Specific Services
- 35. Unix Specific Services
- 35.1.
posixThe most common POSIX system calls - 35.2.
pwdThe password database - 35.3.
spwdThe shadow password database - 35.4.
grpThe group database - 35.5.
cryptFunction to check Unix passwords - 35.6.
termiosPOSIX style tty control - 35.7.
ttyTerminal control functions - 35.8.
ptyPseudo-terminal utilities - 35.9.
fcntlThefcntlandioctlsystem calls - 35.10.
pipesInterface to shell pipelines - 35.11.
resourceResource usage information - 35.12.
nisInterface to Suns NIS (Yellow Pages) - 35.13.
syslogUnix syslog library routines
- 35.1.
- 36. Superseded Modules
- 37. Undocumented Modules