Python Services

The modules in this section are primarily used to interact with the Python interpreter and its environment.

atexit

The atexit module is used to register functions to execute when the Python interpreter exits. A single function is provided:

						register(func
						[,
						args
						[,
						kwargs]])
					

Adds function func to a list of functions that will execute when the interpreter exits. args is a tuple of arguments to pass to the function. kwargs is a dictionary of keyword arguments. The function is invoked as func (*args ,**kwargs ).

Note
  • The atexit module should be used instead of setting the sys.exitfunc variable.

See Also sys (116).

copy

The copy module provides functions for making shallow and deep copies of compound objects, including lists, ...

Get Python Essential Reference, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.