]> granicus.if.org Git - python/commitdiff
Added example of using positional and keyword args with atexit.register().
authorFred Drake <fdrake@acm.org>
Tue, 8 Apr 2003 17:46:53 +0000 (17:46 +0000)
committerFred Drake <fdrake@acm.org>
Tue, 8 Apr 2003 17:46:53 +0000 (17:46 +0000)
Based on a suggestion from a reader.

Doc/lib/libatexit.tex

index 6a72cb3a2c30ccfeaf6a98059866f1d2bf15bf7d..c9775d1b6ddf673b503271fd22808507d2188c19 100644 (file)
@@ -72,3 +72,18 @@ def savecounter():
 import atexit
 atexit.register(savecounter)
 \end{verbatim}
+
+Positional and keyword arguments may also be passed to
+\function{register()} to be passed along to the registered function
+when it is called:
+
+\begin{verbatim}
+def goodbye(name, adjective):
+    print 'Goodbye, %s, it was %s to meet you.' % (name, adjective)
+
+import atexit
+atexit.register(goodbye, 'Donny', 'nice')
+
+# or:
+atexit.register(goodbye, adjective='nice', name='Donny')
+\end{verbatim}