The Python Library Reference - University of Idaho
The Python Library Reference
Release 3.2.3
Guido van Rossum
Fred L. Drake, Jr., editor
June 18, 2012
Python Software Foundation
Email: docs@
CONTENTS
1
Introduction
3
2
Built-in Functions
5
3
Built-in Constants
3.1 Constants added by the site module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
25
25
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 ¡ª str, bytes, bytearray, list, tuple, range
4.7 Set Types ¡ª set, frozenset . . . . . . . . . . . . . . . . . . . . . .
4.8 Mapping Types ¡ª dict . . . . . . . . . . . . . . . . . . . . . . . . . .
4.9 memoryview type . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.10 Context Manager Types . . . . . . . . . . . . . . . . . . . . . . . . . .
4.11 Other Built-in Types . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.12 Special Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
27
27
27
28
28
34
35
46
48
52
54
55
57
5
Built-in Exceptions
5.1 Exception hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
59
63
6
String Services
6.1 string ¡ª Common string operations . . . . .
6.2 re ¡ª Regular expression operations . . . . . .
6.3 struct ¡ª Interpret bytes as packed binary data
6.4 difflib ¡ª Helpers for computing deltas . . .
6.5 textwrap ¡ª Text wrapping and filling . . . .
6.6 codecs ¡ª Codec registry and base classes . .
6.7 unicodedata ¡ª Unicode Database . . . . .
6.8 stringprep ¡ª Internet String Preparation . .
7
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
65
65
74
91
95
105
107
121
123
Data Types
7.1 datetime ¡ª Basic date and time types . . . . .
7.2 calendar ¡ª General calendar-related functions
7.3 collections ¡ª Container datatypes . . . . . .
7.4 heapq ¡ª Heap queue algorithm . . . . . . . . .
7.5 bisect ¡ª Array bisection algorithm . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
125
125
150
153
169
172
i
7.6
7.7
7.8
7.9
7.10
7.11
7.12
7.13
8
9
array ¡ª Efficient arrays of numeric values . .
sched ¡ª Event scheduler . . . . . . . . . . .
queue ¡ª A synchronized queue class . . . . .
weakref ¡ª Weak references . . . . . . . . . .
types ¡ª Names for built-in types . . . . . . .
copy ¡ª Shallow and deep copy operations . . .
pprint ¡ª Data pretty printer . . . . . . . . .
reprlib ¡ª Alternate repr() implementation
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
174
177
179
181
185
186
187
191
Numeric and Mathematical Modules
8.1 numbers ¡ª Numeric abstract base classes . . . . . . . . . . .
8.2 math ¡ª Mathematical functions . . . . . . . . . . . . . . . .
8.3 cmath ¡ª Mathematical functions for complex numbers . . . .
8.4 decimal ¡ª Decimal fixed point and floating point arithmetic
8.5 fractions ¡ª Rational numbers . . . . . . . . . . . . . . .
8.6 random ¡ª Generate pseudo-random numbers . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
195
195
198
202
205
229
231
Functional Programming Modules
237
9.1 itertools ¡ª Functions creating iterators for efficient looping . . . . . . . . . . . . . . . . . . . 237
9.2 functools ¡ª Higher-order functions and operations on callable objects . . . . . . . . . . . . . . 250
9.3 operator ¡ª Standard operators as functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
10 File and Directory Access
10.1 os.path ¡ª Common pathname manipulations . . . . . . .
10.2 fileinput ¡ª Iterate over lines from multiple input streams
10.3 stat ¡ª Interpreting stat() results . . . . . . . . . . . . .
10.4 filecmp ¡ª File and Directory Comparisons . . . . . . . .
10.5 tempfile ¡ª Generate temporary files and directories . . .
10.6 glob ¡ª Unix style pathname pattern expansion . . . . . . .
10.7 fnmatch ¡ª Unix filename pattern matching . . . . . . . . .
10.8 linecache ¡ª Random access to text lines . . . . . . . . .
10.9 shutil ¡ª High-level file operations . . . . . . . . . . . . .
10.10 macpath ¡ª Mac OS 9 path manipulation functions . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
261
261
264
267
271
272
275
276
277
278
283
11 Data Persistence
11.1 pickle ¡ª Python object serialization . . . . . . . . . .
11.2 copyreg ¡ª Register pickle support functions . . . .
11.3 shelve ¡ª Python object persistence . . . . . . . . . . .
11.4 marshal ¡ª Internal Python object serialization . . . . .
11.5 dbm ¡ª Interfaces to Unix ¡°databases¡± . . . . . . . . . .
11.6 sqlite3 ¡ª DB-API 2.0 interface for SQLite databases
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
285
285
296
296
299
300
303
12 Data Compression and Archiving
12.1 zlib ¡ª Compression compatible with gzip
12.2 gzip ¡ª Support for gzip files . . . . . . .
12.3 bz2 ¡ª Compression compatible with bzip2
12.4 zipfile ¡ª Work with ZIP archives . . . .
12.5 tarfile ¡ª Read and write tar archive files
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
323
323
325
327
329
334
13 File Formats
13.1 csv ¡ª CSV File Reading and Writing . . . . . . . . . . .
13.2 configparser ¡ª Configuration file parser . . . . . . .
13.3 netrc ¡ª netrc file processing . . . . . . . . . . . . . . .
13.4 xdrlib ¡ª Encode and decode XDR data . . . . . . . . .
13.5 plistlib ¡ª Generate and parse Mac OS X .plist files
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
343
343
349
365
366
369
ii
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
14 Cryptographic Services
371
14.1 hashlib ¡ª Secure hashes and message digests . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371
14.2 hmac ¡ª Keyed-Hashing for Message Authentication . . . . . . . . . . . . . . . . . . . . . . . . . 373
15 Generic Operating System Services
15.1 os ¡ª Miscellaneous operating system interfaces . . . . . . . . . . . . . . . . .
15.2 io ¡ª Core tools for working with streams . . . . . . . . . . . . . . . . . . . .
15.3 time ¡ª Time access and conversions . . . . . . . . . . . . . . . . . . . . . .
15.4 argparse ¡ª Parser for command-line options, arguments and sub-commands
15.5 optparse ¡ª Parser for command line options . . . . . . . . . . . . . . . . .
15.6 getopt ¡ª C-style parser for command line options . . . . . . . . . . . . . . .
15.7 logging ¡ª Logging facility for Python . . . . . . . . . . . . . . . . . . . . .
15.8 logging.config ¡ª Logging configuration . . . . . . . . . . . . . . . . . .
15.9 logging.handlers ¡ª Logging handlers . . . . . . . . . . . . . . . . . . .
15.10 getpass ¡ª Portable password input . . . . . . . . . . . . . . . . . . . . . . .
15.11 curses ¡ª Terminal handling for character-cell displays . . . . . . . . . . . .
15.12 curses.textpad ¡ª Text input widget for curses programs . . . . . . . . . .
15.13 curses.ascii ¡ª Utilities for ASCII characters . . . . . . . . . . . . . . . .
15.14 curses.panel ¡ª A panel stack extension for curses . . . . . . . . . . . . .
15.15 platform ¡ª Access to underlying platform¡¯s identifying data . . . . . . . . .
15.16 errno ¡ª Standard errno system symbols . . . . . . . . . . . . . . . . . . . .
15.17 ctypes ¡ª A foreign function library for Python . . . . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
375
375
402
412
418
446
471
474
487
496
506
506
522
523
525
527
530
536
16 Optional Operating System Services
16.1 select ¡ª Waiting for I/O completion . . . . . . . . . . . . . . . . . . . .
16.2 threading ¡ª Thread-based parallelism . . . . . . . . . . . . . . . . . .
16.3 multiprocessing ¡ª Process-based parallelism . . . . . . . . . . . . .
16.4 concurrent.futures ¡ª Launching parallel tasks . . . . . . . . . . . .
16.5 mmap ¡ª Memory-mapped file support . . . . . . . . . . . . . . . . . . . .
16.6 readline ¡ª GNU readline interface . . . . . . . . . . . . . . . . . . . .
16.7 rlcompleter ¡ª Completion function for GNU readline . . . . . . . . .
16.8 dummy_threading ¡ª Drop-in replacement for the threading module
16.9 _thread ¡ª Low-level threading API . . . . . . . . . . . . . . . . . . . .
16.10 _dummy_thread ¡ª Drop-in replacement for the _thread module . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
569
569
574
585
635
640
643
646
647
647
649
17 Interprocess Communication and Networking
17.1 subprocess ¡ª Subprocess management . . . . . . . . . . . .
17.2 socket ¡ª Low-level networking interface . . . . . . . . . . .
17.3 ssl ¡ª TLS/SSL wrapper for socket objects . . . . . . . . . . .
17.4 signal ¡ª Set handlers for asynchronous events . . . . . . . .
17.5 asyncore ¡ª Asynchronous socket handler . . . . . . . . . . .
17.6 asynchat ¡ª Asynchronous socket command/response handler
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
651
651
663
675
689
692
696
18 Internet Data Handling
18.1 email ¡ª An email and MIME handling package . . . . . . . .
18.2 json ¡ª JSON encoder and decoder . . . . . . . . . . . . . . .
18.3 mailcap ¡ª Mailcap file handling . . . . . . . . . . . . . . . .
18.4 mailbox ¡ª Manipulate mailboxes in various formats . . . . . .
18.5 mimetypes ¡ª Map filenames to MIME types . . . . . . . . .
18.6 base64 ¡ª RFC 3548: Base16, Base32, Base64 Data Encodings
18.7 binhex ¡ª Encode and decode binhex4 files . . . . . . . . . . .
18.8 binascii ¡ª Convert between binary and ASCII . . . . . . . .
18.9 quopri ¡ª Encode and decode MIME quoted-printable data . .
18.10 uu ¡ª Encode and decode uuencode files . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
701
701
733
739
740
756
759
761
762
763
764
iii
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- python library for statistics
- python library path
- python library path linux
- vscode python library path
- python library search path
- the python language reference pdf
- library reference books
- the python language reference manual
- the reference manual of pediatric dentistry
- of the british library ielts listening
- anaconda python library path
- python library download