O'Reilly logo

Python: Essential Reference, Third Edition by David Beazley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required