Skip to content
Search

Python:StandardLibrary

lastmod 2025-06-12created 2022-07-183 edits

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.

Text Processing Services

  • Python:string - Common string operations
  • Python:re - Regular expression operations
  • Python:difflib - Helpers for computing deltas
  • Python:textwrap - Text wrapping and filling
    • Python:textwrap#shorten - Truncate a string with an ellipsis
    • Python:textwrap#wrap - Wrap a string into lines
  • Python:unicodedata - Unicode database
  • Python:stringprep - Internet string preparation
  • Python:readline - GNU readline interface
  • Python:rlcompleter - Completion function for GNU readline

Binary Data Services

  • Python:struct - Interpret bytes as packed binary data
  • Python:codecs - Codec registry and base classes

Data Types

Numeric and Mathematical Modules

Functional Programming Modules

File and Directory Access

  • Python:pathlib - Object-oriented file system paths
  • Python:os.path - Common pathname manipulations
  • Python:fileinput - Iterate over lines from multiple input streams
  • Python:stat - Interpreting stat() results
  • Python:filecmp - File and directory comparisons
  • Python:tempfile - Generate temporary files and directories
  • Python:glob - Unix style pathname pattern expansion
  • Python:fnmatch - Unix filename pattern matching
  • Python:linecache - Random access to text lines
  • Python:shutil - High-level file operations

Data Persistence

  • Python:pickle - Python object serialization
  • Python:copyreg - Register pickle support functions
  • Python:shelve - Python object persistence
  • Python:marshal - Internal Python object serialization
  • Python:dbm - Interfaces to Unix "databases"
  • Python:sqlite3 - DB-API 2.0 interface for SQLite databases

Data Compression and Archiving

  • Python:zlib - Compression compatible with gzip
  • Python:gzip - Support for gzip files
  • Python:bz2 - Support for bzip2 compression
  • Python:lzma - Compression using the LZMA algorithm
  • Python:zipfile - Work with ZIP archives
  • Python:tarfile - Read and write tar archive files

File Formats

  • Python:csv - CSV file reading and writing
  • Python:configparser - Configuration file parser
  • Python:netrc - netrc file processing
  • Python:xdrlib - Encode and decode XDR data
  • Python:plistlib - Generate and parse Apple .plist files

Cryptographic Services

  • Python:hashlib - Secure hashes and message digests
  • Python:hmac - Keyed-hashing for message authentication
  • Python:secrets - Generate secure random numbers for managing secrets

Generic Operating System Services

  • Python:os - Miscellaneous operating system interfaces
  • Python:io - Core tools for working with streams - includes the ByteIO object.
  • Python:time - Time access and conversions
  • Python:argparse - Parser for command-line options, arguments and sub-commands
  • Python:getopt - C-style parser for command line options
  • Python:logging - Logging facility for Python
  • Python:logging.config - Logging configuration
  • Python:logging.handlers - Logging handlers
  • Python:getpass - Portable password input
  • Python:curses - Terminal handling for character-cell displays
  • Python:curses.textpad - Text input widget for curses programs
  • Python:curses.ascii - Utilities for ASCII characters
  • Python:curses.panel - A panel stack extension for curses
  • Python:platform - Access to underlying platform's identifying data
  • Python:errno - Standard errno system symbols
  • Python:ctypes - A foreign function library for Python

Concurrent Execution

Networking and Interprocess Communication

  • Python:asyncio - Asynchronous I/O
  • Python:socket - Low-level networking interface
  • Python:ssl - TLS/SSL wrapper for socket objects
  • Python:select - Waiting for I/O completion
  • Python:selectors - High-level I/O multiplexing
  • Python:asyncore - Asynchronous socket handler
  • Python:asynchat - Asynchronous socket command/response handler
  • Python:signal - Set handlers for asynchronous events
  • Python:mmap - Memory-mapped file support

Internet Data Handling

  • Python:email - An email and MIME handling package
  • Python:json - JSON encoder and decoder
  • Python:mailcap - Mailcap file handling
  • Python:mailbox - Manipulate mailboxes in various formats
  • Python:mimetypes - Map filenames to MIME types
  • Python:base64 - Base16, Base32, Base64, Base85 data encodings
  • Python:binhex - Encode and decode binhex4 files
  • Python:binascii - Convert between binary and ASCII
  • Python:quopri - Encode and decode MIME quoted-printable data
  • Python:uu - Encode and decode uuencode files

Structured Markup Processing Tools

  • Python:html - HyperText Markup Language support
  • Python:html.parser - Simple HTML and XHTML parser
  • Python:html.entities - Definitions of HTML general entities
  • XML processing modules
  • Python:xml.etree.ElementTree - ElementTree XML API
  • Python:xml.dom - The Document Object Model API
  • Python:xml.dom.minidom - Minimal DOM implementation
  • Python:xml.dom.pulldom - Support for building partial DOM trees
  • Python:xml.sax - Support for SAX2 parsers
  • Python:xml.sax.handler - Base classes for SAX handlers
  • Python:xml.sax.saxutils - SAX utilities
  • Python:xml.sax.xmlreader - Interface for XML parsers
  • Python:xml.parsers.expat - Fast XML parsing using Expat

Internet Protocols and Support

  • Python:webbrowser - Convenient web-browser controller
  • Python:cgi - Common Gateway Interface support
  • Python:cgitb - Traceback manager for CGI scripts
  • Python:wsgiref - WSGI utilities and reference implementation
  • Python:urllib - URL handling modules
  • Python:urllib.request - Extensible library for opening URLs
  • Python:urllib.response - Response classes used by urllib
  • Python:urllib.parse - Parse URLs into components
  • Python:urllib.error - Exception classes raised by urllib.request
  • Python:urllib.robotparser - Parser for robots.txt
  • Python:http - HTTP modules
  • Python:http.client - HTTP protocol client
  • Python:ftplib - FTP protocol client
  • Python:poplib - POP3 protocol client
  • Python:imaplib - IMAP4 protocol client
  • Python:nntplib - NNTP protocol client
  • Python:smtplib - SMTP protocol client
  • Python:smtpd - SMTP Server
  • Python:telnetlib - Telnet client
  • Python:uuid - UUID objects according to RFC 4122
  • Python:socketserver - A framework for network servers
  • Python:http.server - HTTP servers
  • Python:http.cookies - HTTP state management
  • Python:http.cookiejar - Cookie handling for HTTP clients
  • Python:xmlrpc - XMLRPC server and client modules
  • Python:xmlrpc.client - XML-RPC client access
  • Python:xmlrpc.server - Basic XML-RPC servers
  • Python:ipaddress - IPv4/IPv6 manipulation library

Multimedia Services

  • Python:audioop - Manipulate raw audio data
  • Python:aifc - Read and write AIFF and AIFC files
  • Python:sunau - Read and write Sun AU files
  • Python:wave - Read and write WAV files
  • Python:chunk - Read IFF chunked data
  • Python:colorsys - Conversions between color systems
  • Python:imghdr - Determine the type of an image
  • Python:sndhdr - Determine the type of a sound file
  • Python:ossaudiodev - Access to OSS-compatible audio devices

Internationalization

  • Python:gettext - Multilingual internationalization services
  • Python:locale - Internationalization services

Program Frameworks

  • Python:turtle - Turtle graphics
  • Python:cmd - Support for line-oriented command interpreters
  • Python:shlex - Simple lexical analysis

Graphical User Interfaces with Tk

  • Tkinter
  • Python:tkinter - Python interface to Tcl/Tk
  • Python:tkinter.colorchooser - Color choosing dialog
  • Python:tkinter.font - Tkinter font wrapper
  • Tkinter dialogs
  • Python:tkinter.messagebox - Tkinter message prompts
  • Python:tkinter.scrolledtext - Scrolled Text widget
  • Python:tkinter.dnd - Drag and drop support
  • Python:tkinter.ttk - Tk themed widgets
  • Python:tkinter.tix - Extension widgets for Tk

Development Tools

  • Python:typing - Support for type hints
  • Python:pydoc - Documentation generator and online help system
  • Python Development Mode
  • Effects of the Python Development Mode
  • ResourceWarning example
  • Bad file descriptor error example
  • Python:doctest - Test interactive Python examples
  • Python:unittest - Unit testing framework
  • Python:unittest.mock - Mock object library
  • Python:unittest.mock - Getting started
  • Python:2to3 - Automated Python 2 to 3 code translation. A similar tool is six.
  • Python:test - Regression tests package for Python
  • Python:test.support - Utilities for the Python test suite
  • Python:test.support.socket_helper - Utilities for socket tests
  • Python:test.support.script_helper - Utilities for the Python execution tests
  • Python:test.support.bytecode_helper - Support tools for testing correct bytecode generation

Debugging and Profiling

  • Audit events table
  • Python:bdb - Debugger framework
  • Python:faulthandler - Dump the Python traceback
  • Python:pdb - The Python debugger
  • The Python profilers
  • Python:timeit - Measure execution time of small code snippets
  • Python:trace - Trace Python statement execution
  • Python:tracemalloc - Trace memory allocations

Software Packaging and Distribution

  • Python:distutils - Building and installing Python modules
  • Python:ensurepip - Bootstrapping the pip installer
  • Python:venv - Creation of virtual environments
  • Python:zipapp - Manage executable Python zip archives

Python Runtime Services

Custom Python Interpreters

  • Python:code - Interpreter base classes
  • Python:codeop - Compile Python code

Importing Modules

  • Python:zipimport - Import modules from Zip archives
  • Python:pkgutil - Package extension utility
  • Python:modulefinder - Find modules used by a script
  • Python:runpy - Locating and executing Python modules
  • Python:importlib - The implementation of import
  • Python:importlib.metadata

Python Language Services

  • Python:parser - Access Python parse trees
  • Python:ast - Abstract syntax trees
  • Python:symtable - Access to the compiler's symbol tables
  • Python:symbol - Constants used with Python parse trees
  • Python:token - Constants used with Python parse trees
  • Python:keyword - Testing for Python keywords
  • Python:tokenize - Tokenizer for Python source
  • Python:tabnanny - Detection of ambiguous indentation
  • Python:pyclbr - Python module browser support
  • Python:py_compile - Compile Python source files
  • Python:compileall - Byte-compile Python libraries
  • Python:dis - Disassembler for Python bytecode
  • Python:pickletools - Tools for pickle developers

Other Services

  • Python:formatter - Generic output formatting

MS Windows Specific Services

  • Python:msilib - Read and write Microsoft Installer files
  • Python:msvcrt - Useful routines from the MS VC++ runtime
  • Python:winreg - Windows registry access
  • Python:winsound - Sound-playing interface for Windows

Unix Specific Services

  • Python:posix - The most common POSIX system calls
  • Python:pwd - The password database
  • Python:spwd - The shadow password database
  • Python:grp - The group database
  • Python:crypt - Function to check Unix passwords
  • Python:termios - POSIX style tty control
  • Python:tty - Terminal control functions
  • Python:pty - Pseudo-terminal utilities
  • Python:fcntl - The fcntl and ioctl system calls
  • Python:pipes - Interface to shell pipelines
  • Python:resource - Resource usage information
  • Python:nis - Interface to Sun's NIS (Yellow Pages)
  • Python:syslog - Unix syslog library routines

Superseded Modules

  • Python:optparse - Parser for command line options
  • Python:imp - Access the import internals

See also

Favorite site

author Zer0 sitemap