mirror of
https://github.com/python/cpython
synced 2026-09-29 09:55:31 +03:00
Added example of using positional and keyword args with atexit.register().
Based on a suggestion from a reader.
This commit is contained in:
parent
de7ad2caac
commit
2c2068c4d1
1 changed files with 15 additions and 0 deletions
|
|
@ -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}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue