Skip to content

Commit 8e71825

Browse files
committed
Added example of using positional and keyword args with atexit.register().
Based on a suggestion from a reader.
1 parent 016337b commit 8e71825

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

Doc/lib/libatexit.tex

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,18 @@ \subsection{\module{atexit} Example \label{atexit-example}}
7272
import atexit
7373
atexit.register(savecounter)
7474
\end{verbatim}
75+
76+
Positional and keyword arguments may also be passed to
77+
\function{register()} to be passed along to the registered function
78+
when it is called:
79+
80+
\begin{verbatim}
81+
def goodbye(name, adjective):
82+
print 'Goodbye, %s, it was %s to meet you.' % (name, adjective)
83+
84+
import atexit
85+
atexit.register(goodbye, 'Donny', 'nice')
86+
87+
# or:
88+
atexit.register(goodbye, adjective='nice', name='Donny')
89+
\end{verbatim}

0 commit comments

Comments
 (0)