summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2021-06-22 17:10:22 (GMT)
committerGitHub <noreply@github.com>2021-06-22 17:10:22 (GMT)
commite6ea428b83acfee86fb83a7f7f76efece801c67a (patch)
treef399781af8c1ebd755e578264c5d3cfa13f2b142
parent01858fbe31e8e0185edfbd3f10172f7c61391c9d (diff)
downloadcpython-e6ea428b83acfee86fb83a7f7f76efece801c67a.zip
cpython-e6ea428b83acfee86fb83a7f7f76efece801c67a.tar.gz
cpython-e6ea428b83acfee86fb83a7f7f76efece801c67a.tar.bz2
[doc] Improve punctuation atexit doc (GH-25629) (GH-26856)
(cherry picked from commit a6b47de07a304eaa37a1c5554ed00a3ec91f8407) Co-authored-by: Géry Ogam <gery.ogam@gmail.com> Co-authored-by: Géry Ogam <gery.ogam@gmail.com>
-rw-r--r--Doc/library/atexit.rst15
1 files changed, 8 insertions, 7 deletions
diff --git a/Doc/library/atexit.rst b/Doc/library/atexit.rst
index c2c058e..e6fa33a 100644
--- a/Doc/library/atexit.rst
+++ b/Doc/library/atexit.rst
@@ -39,7 +39,7 @@ internal error is detected, or when :func:`os._exit` is called.
If an exception is raised during execution of the exit handlers, a traceback is
printed (unless :exc:`SystemExit` is raised) and the exception information is
- saved. After all exit handlers have had a chance to run the last exception to
+ saved. After all exit handlers have had a chance to run, the last exception to
be raised is re-raised.
This function returns *func*, which makes it possible to use it as a
@@ -73,7 +73,7 @@ automatically when the program terminates without relying on the application
making an explicit call into this module at termination. ::
try:
- with open("counterfile") as infile:
+ with open('counterfile') as infile:
_count = int(infile.read())
except FileNotFoundError:
_count = 0
@@ -83,21 +83,22 @@ making an explicit call into this module at termination. ::
_count = _count + n
def savecounter():
- with open("counterfile", "w") as outfile:
- outfile.write("%d" % _count)
+ with open('counterfile', 'w') as outfile:
+ outfile.write('%d' % _count)
import atexit
+
atexit.register(savecounter)
Positional and keyword arguments may also be passed to :func:`register` to be
passed along to the registered function when it is called::
def goodbye(name, adjective):
- print('Goodbye, %s, it was %s to meet you.' % (name, adjective))
+ print('Goodbye %s, it was %s to meet you.' % (name, adjective))
import atexit
- atexit.register(goodbye, 'Donny', 'nice')
+ atexit.register(goodbye, 'Donny', 'nice')
# or:
atexit.register(goodbye, adjective='nice', name='Donny')
@@ -107,6 +108,6 @@ Usage as a :term:`decorator`::
@atexit.register
def goodbye():
- print("You are now leaving the Python sector.")
+ print('You are now leaving the Python sector.')
This only works with functions that can be called without arguments.