diff options
| author | Fred Drake <fdrake@acm.org> | 2003-04-08 17:46:33 +0000 |
|---|---|---|
| committer | Fred Drake <fdrake@acm.org> | 2003-04-08 17:46:33 +0000 |
| commit | 71e300eeea9b127bb8bd6dd380bbcffd4746630f (patch) | |
| tree | 632e35c8670a7124d797085270e4aa10d9b9a35e /Doc | |
| parent | d90042536dcc94720db3ef845a2dd8a285059fd4 (diff) | |
| download | cpython-git-71e300eeea9b127bb8bd6dd380bbcffd4746630f.tar.gz | |
Added example of using positional and keyword args with atexit.register().
Based on a suggestion from a reader.
Diffstat (limited to 'Doc')
| -rw-r--r-- | Doc/lib/libatexit.tex | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Doc/lib/libatexit.tex b/Doc/lib/libatexit.tex index 6a72cb3a2c..c9775d1b6d 100644 --- a/Doc/lib/libatexit.tex +++ b/Doc/lib/libatexit.tex @@ -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} |
