Skip to Content
Python: Essential Reference, Third Edition
book

Python: Essential Reference, Third Edition

by David Beazley
February 2006
Intermediate to advanced content levelIntermediate to advanced
648 pages
14h 53m
English
Sams
Content preview from Python: Essential Reference, Third Edition

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

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python: Essential Reference

Python: Essential Reference

David M. Beazley

Publisher Resources

ISBN: 0672328623Purchase book