February 2006
Intermediate to advanced
648 pages
14h 53m
English
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 tuple of arguments to pass to the function. kwargs is a dictionary of keyword arguments. The function is invoked as func(*args,**kwargs). Upon exit, functions are invoked in reverse order of registration (the most recently added exit function is invoked first). If an error occurs, an exception message will be printed to standard error, but will otherwise be ignored.
Note
The atexit module should be used instead of setting the sys.exitfunc variable directly because doing so may interfere ...