Fork me on GitHub , Connect via LinkedIn, Columbia University Email, Donate or Buy Coffee
flowchart LR
classDef blue fill:#2196f3,stroke:#fff,stroke-width:2px;
classDef green fill:#4caf50,stroke:#fff,stroke-width:2px;
classDef yellow fill:#ffeb3b,stroke:#000,stroke-width:2px;
classDef orange fill:#ff9800,stroke:#fff,stroke-width:2px;
classDef red fill:#f44336,stroke:#fff,stroke-width:2px;
classDef purple fill:#9c27b0,stroke:#fff,stroke-width:2px;
classDef white color:#022e1f,fill:#fff;
a[Python Language]:::blue --> b[Tutorial]:::green --> c[Standard Library]:::purple
c-->d[Design Patterns]:::white
c-->e[DS & Algorithms]:::white
d-->f[Python Projects]:::purple
e-->f[Python Projects]:::purple
Table of Contents : 0 : Introduction, 1 : Built-in Functions, 2 : Built-in Constants, 3 : Built-in Types, 4 : Built-in Exceptions, 5 : Text Processing Services, 6 : Binary Data Services, 7 : Data Types, 8 : Numeric and Mathematical Modules, 9 : Functional Programming Modules, 10 : File and Directory Access, 11 : Data Persistence, 12 : Data Compression and Archiving, 13 : File Formats, 14 : Cryptographic Services, 15 : Generic Operating System Services, 16 : Concurrent Execution, 17 : Networking and Interprocess Communication, 18 : Internet Data Handling, 19 : Structured Markup Processing Tools, 20 : Internet Protocols and Support, 21 : Multimedia Services, 22 : Internationalization, 23 : Program Frameworks, 24 : Graphical User Interfaces with Tk, 25 : Development Tools, 26 : Debugging and Profiling, 27 : Software Packaging and Distribution, 28 : Python Runtime Services, 29 : Custom Python Interpreters, 30 : Importing Modules, 31 : Python Language Services, 32 : MS Windows Specific Services, 33 : Unix Specific Services, 34 : Superseded Modules, 35 : Security Considerations.
This is a comprehesive cheatsheet based on the official Python Standard Library. The aim is to offer users practical example implementation of the core Python language
Python built-in functions and exceptions are programming objects that can be used by all Python code without the need of the use of an import statement to invoke librarie(s) and module(s).
1. Built-in Functions: A :, abs(), aiter(), all(), any(), anext(), ascii(), B, bin(), bool(), breakpoint(), bytearray(), bytes(), C, callable(), chr(), classmethod(), compile(), complex(), D, delattr(), dict(), dir(), divmod(), E, enumerate(), eval(), exec(), F, filter(), float(), format(), frozenset(), G, getattr(), globals(), H, hasattr(), hash(), help(), hex(), I, id(), input(), int(), isinstance(), issubclass(), iter(), L, len(), list(), locals(), M, map(), max(), memoryview(), min(), N, next(), O, object(), oct(), open(), ord(), P, pow(), print(), property(), R, range(), repr(), reversed(), round(), S, set(), setattr(), slice(), sorted(), staticmethod(), str(), sum(), super(), T, tuple(), type(), V, vars(), Z, zip(), __import__().
| A | D | I | O | S |
|---|---|---|---|---|
abs() |
delattr() |
id() |
object() |
set() |
aiter() |
dict() |
input() |
oct() |
setattr() |
all() |
dir() |
int() |
open() |
slice() |
any() |
divmod() |
isinstance() |
ord() |
sorted() |
anext() |
E | issubclass() |
P | staticmethod() |
ascii() |
enumerate() |
iter() |
pow() |
str() |
| B | eval() |
L | print() |
sum() |
bin() |
exec() |
len() |
property() |
super() |
bool() |
F | list() |
R | T |
breakpoint() |
filter() |
locals() |
range() |
tuple() |
bytearray() |
float() |
M | repr() |
type() |
bytes() |
format() |
map() |
reversed() |
--- |
| C | frozenset() |
max() |
round() |
__import__() |
callable() |
G | memoryview() |
V | |
chr() |
getattr() |
min() |
vars() |
|
classmethod() |
globals() |
N | Z | |
compile() |
next() |
zip() |
||
complex() |
The abs() function in Python returns the absolute value of a given number. The absolute value of a number is the distance of the number from zero, regardless of whether the number is positive or negative. The syntax for using the abs() function is as follows:
python Copy code abs(x) where x is the number for which you want to find the absolute value.
Here are some examples of using the abs() function:
print(abs(5)) # Output: 5
print(abs(-5)) # Output: 5
print(abs(0)) # Output: 0
print(abs(3.14)) # Output: 3.14
print(abs(-3.14)) # Output: 3.14As you can see from the examples, the abs() function works with both integers and floating-point numbers.
If you try to pass a non-numeric value to the abs() function, you will get a TypeError:
print(abs('hello'))
# Output: TypeError: bad operand type for abs(): 'str'c = 5 + 3j
print(abs(c))
# Output: 5.830951894845301In this example, we have assigned a complex number 5 + 3j to the variable c. When we call the abs() function with the parameter c, the function returns the magnitude of the complex number, which is calculated as the square root of the sum of the squares of the real and imaginary parts. Therefore, the output is 5.830951894845301.
In summary, the abs() function is a built-in Python function that returns the absolute value of a number. It is a useful function for finding the distance of a number from zero, regardless of whether the number is positive or negative.
| # | Use Case | Python Code Example |
|---|---|---|
| 1 | Find the absolute value of a given number |
num = -10
abs_num = abs(num)
print(abs_num) # Output: 10 |
| 2 | Calculate the distance between two numbers on a number line |
num1 = 10
num2 = 20
distance = abs(num1 - num2)
print(distance) # Output: 10 |
| 3 | Determine the magnitude or amplitude of a vector in physics |
import cmath
vector = 3 + 4j
magnitude = abs(vector)
print(magnitude) # Output: 5.0 |
| 4 | Determine the magnitude or amplitude of a vector in physics |
a = 20
b = -30
difference = abs(a - b)
print(difference) # Output: 50 |
| 5 | Normalize data by converting negative values to positive values |
data = [1, -2, 3, -4, 5]
normalized_data = [abs(x) for x in data]
print(normalized_data) # Output: [1, 2, 3, 4, 5] |
| 6 | Calculate the modulus or remainder of a number without considering its sign |
num = -10
divisor = 3
modulus = abs(num) % divisor
print(modulus) # Output: 1 |
| 7 | Convert a complex number to its magnitude or modulus |
complex_num = 2 + 3j
magnitude = abs(complex_num)
print(magnitude) # Output: 3.605551275463989 |
| 8 | Determine the error or deviation of a measurement from its true value |
measurement = 10
true_value = 15
error = abs(measurement - true_value)
print(error) # Output: 5 |
| 9 | Calculate the absolute difference between two sets of data |
set1 = {1, 2, 3}
set2 = {3, 4, 5}
difference = abs(len(set1) - len(set2))
print(difference) # Output: 2 |
| 10 | Evaluate mathematical expressions involving absolute values, such as inequalities or distance formulas |
a = 10
b = 20
if abs(a - b) >= 5:
print("The absolute difference between a and b is greater than or equal to 5")
else:
print("The absolute difference between a and b is less than 5") |
The aiter() function is a built-in Python function that returns an asynchronous iterator object. It is used to create an asynchronous generator that produces values asynchronously.
An asynchronous iterator is an object that implements the __aiter__() and __anext__() methods. The __aiter__() method returns the asynchronous iterator object itself, while the __anext__() method returns a coroutine that produces the next value in the asynchronous sequence.
Here's an example of how to use the aiter() function:
async def my_async_generator():
for i in range(5):
await asyncio.sleep(1) # wait for 1 second
yield i
async def main():
async for i in aiter(my_async_generator()):
print(i)
await main()In this example, my_async_generator() is an asynchronous generator that produces values asynchronously using the yield statement. The async for loop iterates over the asynchronous generator by calling the __anext__() method to get the next value in the sequence.
The aiter() function is used to create an asynchronous iterator object from the asynchronous generator object returned by my_async_generator(). This allows the async for loop to iterate over the asynchronous sequence produced by the generator.
When you call aiter() on an iterable object, it returns an asynchronous iterator object that can be used with an async for loop to iterate over the values asynchronously. Here's an example:
import asyncio
async def my_coroutine():
async for item in aiter(my_iterable):
print(item)
asyncio.run(my_coroutine())In this example, my_iterable is an iterable object, and aiter() returns an asynchronous iterator object that we can use to iterate over the values in my_iterable asynchronously. The async for loop is used to iterate over the values in the asynchronous iterator, and the print() function is used to output each value as it is encountered.
Note that the aiter() function can also be used with other types of asynchronous iterators, such as asynchronous generators and asynchronous iterables.
Overall, the aiter() function is a powerful tool for working with asynchronous sequences in Python, allowing you to easily create and iterate over asynchronous iterators and generators.
| # | Use Case | Python Code Example |
|---|---|---|
| 1 | Iterating over an asynchronous generator: |
async def async_gen():
for i in range(5):
await asyncio.sleep(1)
yield i
async def my_coroutine():
async for i in asyncio.aiter(async_gen()):
print(i)
asyncio.run(my_coroutine()) |
| 2 | Iterating over an asynchronous iterable object that returns tasks: |
async def my_coroutine():
tasks = [asyncio.create_task(async_task(i)) for i in range(5)]
async for task in asyncio.aiter(tasks):
await task
async def async_task(i):
await asyncio.sleep(1)
print(i)
asyncio.run(my_coroutine())
|
| 3 | Implementing a custom asynchronous iterable object: |
class MyAsyncIterable:
def __init__(self, start, stop):
self.start = start
self.stop = stop
async def __aiter__(self):
self.current = self.start
return self
async def __anext__(self):
if self.current < self.stop:
await asyncio.sleep(1)
result = self.current
self.current += 1
return result
else:
raise StopAsyncIteration
async def my_coroutine():
async for i in asyncio.aiter(MyAsyncIterable(0, 5)):
print(i)
asyncio.run(my_coroutine())
|
| # | Use Case | Python Code Example |
|---|---|---|
| 1 | Iterating over an asynchronous generator: |
# Check if all elements in a list are greater than 0
lst = [1, 2, 3, 4, 5]
result = all(x > 0 for x in lst)
print(result) # True
# Check if all elements in a tuple are even
tup = (2, 4, 6, 8)
result = all(x % 2 == 0 for x in tup)
print(result) # True
# Check if all elements in a set are strings
s = {'hello', 'world', 'python'}
result = all(isinstance(x, str) for x in s)
print(result) # True
|
| 2 | Checking if an iterable is empty: You can use all() to check if an iterable is empty. If the iterable is empty, all() returns True. Otherwise, it returns False. For example:
|
# Check if a list is empty
lst = []
result = all(lst)
print(result) # True
# Check if a tuple is empty
tup = ()
result = all(tup)
print(result) # True
# Check if a set is empty
s = set()
result = all(s)
print(result) # True
|
| 3 | Checking if a list of conditions is true: You can use all to check if a list of conditions is true. For example:
|
# Check if a number is positive, even, and a multiple of 4
n = 8
conditions = [n > 0, n % 2 == 0, n % 4 == 0]
result = all(conditions)
print(result) # True
# Check if a string is all lowercase and contains only letters
s = 'hello'
conditions = [s.islower(), s.isalpha()]
result = all(conditions)
print(result) # True
|
| # | Use Case | Code Example |
|---|---|---|
| 1 | Check if any element in a list is True |
my_list = [False, False, True, False]
result = any(my_list)
print(result) # Output: True |
| 2 | Check if any character in a string is a digit |
my_string = "Hello, world! 123"
result = any(char.isdigit() for char in my_string)
print(result) # Output: True |
| 3 | Check if any element in a tuple satisfies a condition |
my_tuple = (1, 2, 3, 4, 5)
result = any(x > 3 for x in my_tuple)
print(result) # Output: True |
| 4 | Check if any key in a dictionary is True |
my_dict = {'a': False, 'b': False, 'c': True}
result = any(my_dict.values())
print(result) # Output: True |
| 5 | Check if any file in a directory has a specific extension |
import os
dir_path = "/path/to/directory"
extension = ".txt"
result = any(file.endswith(extension) for file in os.listdir(dir_path))
print(result) |
| 6 | Check if any element in a set is True |
my_set = {False, False, True}
result = any(my_set)
print(result) # Output: True |
| 7 | Check if any element in a range satisfies a condition |
my_range = range(1, 10)
result = any(x > 5 for x in my_range)
print(result) # Output: True |
| 8 | Check if any element in a list satisfies a condition |
any(x > 5 for x in [1, 3, 6, 8]) |
| 9 | Check if any element in a tuple satisfies a condition |
any(x.startswith("a") for x in ("apple", "banana", "orange")) |
| 10 | Check if any element in a set satisfies a condition |
any(len(x) == 3 for x in {"cat", "dog", "elephant"}) |
| 11 | Check if any element in a dictionary satisfies a condition |
any(value > 10 for key, value in {"apple": 5, "banana": 12, "orange": 8}.items()) |
| # | Use Case | Python Code Example |
|---|---|---|
| 1 | Iterate through an asynchronous iterator until the next item is available |
import asyncio
async def my_coroutine():
my_list = ['apple', 'banana', 'cherry']
my_iterator = iter(my_list)
while True:
try:
item = await anext(my_iterator)
print(item)
except StopAsyncIteration:
break
asyncio.run(my_coroutine())
'''
Output Result :
apple
banana
cherry
''' |
| 2 | Get the next item from an asynchronous iterator if available, otherwise return a default value |
import asyncio
async def my_coroutine():
my_list = ['apple', 'banana', 'cherry']
my_iterator = iter(my_list)
while True:
item = await anext(my_iterator, default=None)
if item is None:
break
else:
print(item)
asyncio.run(my_coroutine())
'''
Output Result :
apple
banana
cherry
''' |
| 3 | Get the next item from an asynchronous iterator within a timeout period |
import asyncio
async def my_coroutine():
my_list = ['apple', 'banana', 'cherry']
my_iterator = iter(my_list)
while True:
try:
item = await asyncio.wait_for(anext(my_iterator), timeout=1.0)
print(item)
except StopAsyncIteration:
break
except asyncio.TimeoutError:
print("Timed out")
asyncio.run(my_coroutine())
'''
Output Result :
apple
banana
cherry
''' |
| 4 | Iterating through an asynchronous iterator |
async def async_gen():
yield 1
yield 2
yield 3
async def main():
async for item in async_gen():
print(item)
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
'''
# Output:
# 1
# 2
# 3
''' |
| 5 | Getting the next value from an asynchronous iterator |
async def async_gen():
yield 1
yield 2
yield 3
async def main():
ag = async_gen()
print(await anext(ag)) # 1
print(await anext(ag)) # 2
print(await anext(ag)) # 3
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
'''
# Output:
# 1
# 2
# 3
''' |
| 6 | Handling StopAsyncIteration when there are no more items |
async def async_gen():
yield 1
yield 2
yield 3
async def main():
ag = async_gen()
print(await anext(ag)) # 1
print(await anext(ag)) # 2
print(await anext(ag)) # 3
try:
print(await anext(ag))
except StopAsyncIteration:
print("No more items")
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
'''
# Output:
# 1
# 2
# 3
''' |
| # | Use Case | Python Code Example |
|---|---|---|
| 1 | Check if a string contains any non-ASCII characters |
my_string = "Hello, world! 😊"
result = all(ord(char) < 128 for char in my_string)
print(result) # Output: False |
| 2 | Check if a string contains only ASCII characters |
my_string = "Hello, world!"
result = all(ord(char) < 128 for char in my_string)
print(result) # Output: True |
| 3 | Convert a byte string containing non-ASCII characters to ASCII |
my_bytes = b"Hello, world! \xe2\x98\x83"
result = my_bytes.decode('ascii', 'ignore')
print(result) # Output: b"Hello, world! " |
| 4 | Convert a bytes object to its ASCII representation |
my_bytes = b"Hello, world! \xe2\x98\x83"
result = ascii(my_bytes)
print(result) # Output: b'Hello, world! \\xe2\\x98\\x83' |
| 5 | Convert a dictionary containing non-ASCII keys to ASCII |
my_dict = {'møøse': 'funny', 'spam': 'eggs'}
result = ascii(my_dict)
print(result) # Output: "{'m\\xf8\\xf8se': 'funny', 'spam': 'eggs'}" |
| 6 | Convert a set containing non-ASCII characters to ASCII |
my_set = {'møøse', 'spam'}
result = ascii(my_set)
print(result) # Output: "{'m\\xf8\\xf8se', 'spam'}" |
| 7 | Convert a string containing non-ASCII characters to ASCII |
my_string = "Hello, world! 😊"
result = ascii(my_string)
print(result) # Output: "'Hello, world! \\U0001f60a'" |
| 8 | Convert a string to its ASCII representation |
my_string = "Hello, world!"
result = ascii(my_string)
print(result) # Output: "'Hello, world!'" |
| 9 | Check if a string contains any non-ASCII characters |
my_string = "Hello, world! ±"
result = any(ord(char) > 127 for char in my_string)
print(result) # Output: True |
| 10 | Check if a string contains only ASCII characters |
my_string = "Hello, world!"
result = all(ord(char) < 128 for char in my_string)
print(result) # Output: True |
| 11 | Convert a byte string containing non-ASCII characters to ASCII |
my_bytes = b'Hello, world! ±'
result = my_bytes.decode('ascii', 'ignore')
print(result) # Output: b'Hello, world! ' |
| 12 | Convert a bytes object to its ASCII representation |
my_bytes = b'Hello, world!'
result = ascii(my_bytes)
print(result) # Output: b'Hello, world!' |
| 13 | Convert a dictionary containing non-ASCII keys to ASCII |
my_dict = {'Héllo': 'world'}
result = {ascii(key): value for key, value in my_dict.items()}
print(result) # Output: {'H\\xe9llo': 'world'} |
| 14 | Convert a set containing non-ASCII characters to ASCII |
my_set = {'Héllo', 'wörld'}
result = set(ascii(char) for char in my_set)
print(result) # Output: {'H\\xe9llo', 'w\\xf6rld'} |
| 15 | Convert a string containing non-ASCII characters to ASCII |
my_string = "Héllo, wörld!"
result = ascii(my_string)
print(result) # Output: 'H\\xe9llo, w\\xf6rld!' |
| # | Use Case | Python Code Example |
|---|---|---|
| 1 | Convert an integer to a binary string |
num = 10
binary_string = bin(num)
print(binary_string) |
| 2 | Convert an integer to a binary string with a prefix |
num = 10
binary_string = '0b' + bin(num)[2:]
print(binary_string) |
| 3 | Convert a byte to a binary string |
b = b'\x0f'
binary_string = bin(int.from_bytes(b, byteorder='big'))
print(binary_string) |
| 4 | Convert a bytearray to a binary string |
b = bytearray(b'\x0f\x1e\x2d\x3c')
binary_string = ''.join(bin(i)[2:].zfill(8) for i in b)
print(binary_string) |
| 5 | Convert a list of integers to a binary string |
nums = [1, 2, 3, 4]
binary_string = ''.join(bin(i)[2:].zfill(8) for i in nums)
print(binary_string) |
| 6 | Convert a tuple of integers to a binary string |
nums = (1, 2, 3, 4)
binary_string = ''.join(bin(i)[2:].zfill(8) for i in nums)
print(binary_string) |
| 7 | Convert a set of integers to a binary string |
nums = {1, 2, 3, 4}
binary_string = ''.join(bin(i)[2:].zfill(8) for i in nums)
print(binary_string) |
| 8 | Convert a binary string to an integer |
binary_string = '0b1010'
num = int(binary_string, 2)
print(num) |
| # | Use Case | Python Code Example |
|---|---|---|
| 1 | Convert a value to a boolean |
value = "hello"
result = bool(value)
print(result) # Output: True |
| 2 | Check if a value is True |
value = 5
result = bool(value)
print(result) # Output: True |
| 3 | Check if a value is False |
value = ""
result = bool(value)
print(result) # Output: False |
| 4 | Convert an integer to a boolean |
value = 0
result = bool(value)
print(result) # Output: False |
| 5 | Convert a float to a boolean |
value = 0.0
result = bool(value)
print(result) # Output: False |
| 6 | Convert a string to a boolean |
value = "False"
result = bool(value)
print(result) # Output: True |
| 7 | Check if a list is empty |
my_list = []
result = bool(my_list)
print(result) # Output: False |
| 8 | Check if a tuple is empty |
my_tuple = ()
result = bool(my_tuple)
print(result) # Output: False |
| 9 | Check if a dictionary is empty |
my_dict = {}
result = bool(my_dict)
print(result) # Output: False |
| 10 | Check if a set is empty |
my_set = set()
result = bool(my_set)
print(result) # Output: False |
| 11 | Convert a boolean to a string |
value = True
result = str(value)
print(result) # Output: 'True' |
2. Built-in Constants:
3. 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, Type Annotation Types — Generic Alias, Union, Other Built-in Types, Special Attributes, Integer string conversion length limitation.
4. Built-in Exceptions: Exception context, Inheriting from built-in exceptions, Base classes, Concrete exceptions, Warnings, Exception groups, Exception hierarchy.
5. 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.
6. Binary Data Services: struct — Interpret bytes as packed binary data, codecs — Codec registry and base classes.
7. Data Types: datetime — Basic date and time types, zoneinfo — IANA time zone support, 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, graphlib — Functionality to operate with graph-like structures.
8. 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,
9. Functional Programming Modules: itertools — Functions creating iterators for efficient looping, functools — Higher-order functions and operations on callable objects, operator — Standard operators as functions.
10. 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, linecache — Random access to text lines, shutil — High-level file operations.
11. Data Persistence: pickle — Python object serialization, copyreg — Register pickle support functions, shelve — Python object persistence, marshal — Internal Python object serialization, dbm — Interfaces to Unix “databases”, sqlite3 — DB-API 2.0 interface for SQLite databases.
12. Data Compression and Archiving: zlib — Compression compatible with gzip, gzip — Support for gzip files, bz2 — Support for bzip2 compression, lzma — Compression using the LZMA algorithm, zipfile — Work with ZIP archives, tarfile — Read and write tar archive files.
13. File Formats: csv — CSV File Reading and Writing, configparser — Configuration file parser, tomllib — Parse TOML files, netrc — netrc file processing, plistlib — Generate and parse Apple .plist files.
14. Cryptographic Services: hashlib — Secure hashes and message digests, hmac — Keyed-Hashing for Message Authentication, secrets — Generate secure random numbers for managing secrets.
15. Generic Operating System Services: os — Miscellaneous operating system interfaces, io — Core tools for working with streams, time — Time access and conversions, argparse — Parser for command-line options, arguments and sub-commands, getopt — C-style parser for command line options, logging — Logging facility for Python, logging.config — Logging configuration, logging.handlers — Logging handlers, getpass — Portable password input, curses — Terminal handling for character-cell displays, curses.textpad — Text input widget for curses programs, curses.ascii — Utilities for ASCII characters, curses.panel — A panel stack extension for curses, platform — Access to underlying platform’s identifying data, errno — Standard errno system symbols, ctypes — A foreign function library for Python.
16. Concurrent Execution: threading — Thread-based parallelism, multiprocessing — Process-based parallelism, multiprocessing.shared_memory — Shared memory for direct access across processes, The concurrent package, concurrent.futures — Launching parallel tasks, subprocess — Subprocess management, sched — Event scheduler, queue — A synchronized queue class, contextvars — Context Variables, _thread — Low-level threading API.
17. Networking and Interprocess Communication: asyncio — Asynchronous I/O, socket — Low-level networking interface, ssl — TLS/SSL wrapper for socket objects, select — Waiting for I/O completion, selectors — High-level I/O multiplexing, signal — Set handlers for asynchronous events, mmap — Memory-mapped file support.
18. Internet Data Handling: email — An email and MIME handling package, json — JSON encoder and decoder, mailbox — Manipulate mailboxes in various formats, mimetypes — Map filenames to MIME types, base64 — Base16, Base32, Base64, Base85 Data Encodings, binascii — Convert between binary and ASCII, quopri — Encode and decode MIME quoted-printable data.
19. Structured Markup Processing Tools: html — HyperText Markup Language support, html.parser — Simple HTML and XHTML parser, html.entities — Definitions of HTML general entities, XML Processing Modules, xml.etree.ElementTree — The ElementTree XML API, xml.dom — The Document Object Model API, xml.dom.minidom — Minimal DOM implementation, xml.dom.pulldom — Support for building partial DOM trees, xml.sax — Support for SAX2 parsers, xml.sax.handler — Base classes for SAX handlers, xml.sax.saxutils — SAX Utilities, xml.sax.xmlreader — Interface for XML parsers, xml.parsers.expat — Fast XML parsing using Expat.
20. Internet Protocols and Support: webbrowser — Convenient web-browser controller, wsgiref — WSGI Utilities and Reference Implementation, urllib — URL handling modules, urllib.request — Extensible library for opening URLs, urllib.response — Response classes used by urllib, urllib.parse — Parse URLs into components, urllib.error — Exception classes raised by urllib.request, urllib.robotparser — Parser for robots.txt, http — HTTP modules, http.client — HTTP protocol client, ftplib — FTP protocol client, poplib — POP3 protocol client, imaplib — IMAP4 protocol client, smtplib — SMTP protocol client, uuid — UUID objects according to RFC 4122, socketserver — A framework for network servers, http.server — HTTP servers, http.cookies — HTTP state management, http.cookiejar — Cookie handling for HTTP clients, xmlrpc — XMLRPC server and client modules, xmlrpc.client — XML-RPC client access, xmlrpc.server — Basic XML-RPC servers, ipaddress — IPv4/IPv6 manipulation library.
21. Multimedia Services: wave — Read and write WAV files, colorsys — Conversions between color systems.
22. Internationalization: gettext — Multilingual internationalization services, locale — Internationalization services.
23. Program Frameworks: turtle — Turtle graphics, cmd — Support for line-oriented command interpreters, shlex — Simple lexical analysis.
24. Graphical User Interfaces with Tk: tkinter — Python interface to Tcl/Tk, tkinter.colorchooser — Color choosing dialog, tkinter.font — Tkinter font wrapper, Tkinter Dialogs, tkinter.messagebox — Tkinter message prompts, tkinter.scrolledtext — Scrolled Text Widget, tkinter.dnd — Drag and drop support, tkinter.ttk — Tk themed widgets, tkinter.tix — Extension widgets for Tk, IDLE.
25. Development Tools: typing — Support for type hints, pydoc — Documentation generator and online help system, Python Development Mode, Effects of the Python Development Mode, ResourceWarning Example, Bad file descriptor error example, 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.socket_helper — Utilities for socket tests, test.support.script_helper — Utilities for the Python execution tests, test.support.bytecode_helper — Support tools for testing correct bytecode generation, test.support.threading_helper — Utilities for threading tests, test.support.os_helper — Utilities for os tests, test.support.import_helper — Utilities for import tests, test.support.warnings_helper — Utilities for warnings tests.
26. Debugging and Profiling: Audit events table, 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.
27. 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.
28. Python Runtime Services: sys — System-specific parameters and functions, sysconfig — Provide access to Python’s configuration information, builtins — Built-in objects, __main__ — Top-level code 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.
29. Custom Python Interpreters: code — Interpreter base classes, codeop — Compile Python code.
30. 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, importlib.resources – Resources, Deprecated functions, importlib.resources.abc – Abstract base classes for resources, Using importlib.metadata, The initialization of the sys.path module search path.
31. Python Language Services: ast — Abstract Syntax Trees, symtable — Access to the compiler’s symbol tables, token — Constants used with Python parse trees, keyword — Testing for Python keywords, tokenize — Tokenizer for Python source, tabnanny — Detection of ambiguous indentation, pyclbr — Python module browser support, py_compile — Compile Python source files, compileall — Byte-compile Python libraries, dis — Disassembler for Python bytecode, pickletools — Tools for pickle developers.
32. MS Windows Specific Services: msvcrt — Useful routines from the MS VC++ runtime, winreg — Windows registry access, winsound — Sound-playing interface for Windows.
33. Unix Specific Services: posix — The most common POSIX system calls, pwd — The password database, grp — The group database, termios — POSIX style tty control, tty — Terminal control functions, pty — Pseudo-terminal utilities, fcntl — The fcntl and ioctl system calls, resource — Resource usage information, syslog — Unix syslog library routines.
34. Superseded Modules: aifc — Read and write AIFF and AIFC files, asynchat — Asynchronous socket command/response handler, asyncore — Asynchronous socket handler, audioop — Manipulate raw audio data, cgi — Common Gateway Interface support, cgitb — Traceback manager for CGI scripts, chunk — Read IFF chunked data, crypt — Function to check Unix passwords, imghdr — Determine the type of an image, imp — Access the import internals, mailcap — Mailcap file handling, msilib — Read and write Microsoft Installer files, nis — Interface to Sun’s NIS (Yellow Pages), nntplib — NNTP protocol client, optparse — Parser for command line options, ossaudiodev — Access to OSS-compatible audio devices, pipes — Interface to shell pipelines, smtpd — SMTP Server, sndhdr — Determine type of sound file, spwd — The shadow password database, sunau — Read and write Sun AU files, telnetlib — Telnet client, uu — Encode and decode uuencode files, xdrlib — Encode and decode XDR data.
Copyright © Kwadwo Adutwum , 2023
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License

