This guide aims to show examples of use of all Python Library Reference functions, methods and classes. At this point, only the more widely used modules were added and only functions use examples are given. Python version 2.5 was used for examples unless noted otherwise. Example of output of a function is shown in the form of function_call(args) # result, when result is the actual output, it is shown after the comment sign, if it's a description of an outcome, e.g. a raised exception, it will be shown in square brackets:
math.sqrt(9) # 3.0
1/0 # [raises ZeroDivisionError]
Note that use of function is shown as if it was imported directly to current namespace, e.g. pow(2,3) instead of math.pow(9).
sys module - system-specific parameters and functions
pprint module - pretty printing
Regular expressions:
-
re module - regular expressions
re spec. characters - special characters for regular expressions
decimal module - decimal floating point arithmetic
array module - efficient representations of arrays
random module - pseudo-random number generators
sets module - unordered collections of unique elements
struct module - conversion between Python values and C structs
glob module - match filenames by pattern
rlcompleter module - complete valid Python identifiers and keywords
platform module - access to platform's identifying data
shutil module - copyfile, copytree, rmtree, move, ...
tempfile module - generate temporary files and directories
traceback module - print or retrieve a stack traceback
inspect module - inspect live objects such as functions, modules, classes
