Skip to content

Commit e6ea428

Browse files
[doc] Improve punctuation atexit doc (GH-25629) (GH-26856)
(cherry picked from commit a6b47de07a304eaa37a1c5554ed00a3ec91f8407) Co-authored-by: Géry Ogam <[email protected]> Co-authored-by: Géry Ogam <[email protected]>
1 parent 01858fb commit e6ea428

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Doc/library/atexit.rst

+8-7
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ internal error is detected, or when :func:`os._exit` is called.
3939

4040
If an exception is raised during execution of the exit handlers, a traceback is
4141
printed (unless :exc:`SystemExit` is raised) and the exception information is
42-
saved. After all exit handlers have had a chance to run the last exception to
42+
saved. After all exit handlers have had a chance to run, the last exception to
4343
be raised is re-raised.
4444

4545
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
7373
making an explicit call into this module at termination. ::
7474

7575
try:
76-
with open("counterfile") as infile:
76+
with open('counterfile') as infile:
7777
_count = int(infile.read())
7878
except FileNotFoundError:
7979
_count = 0
@@ -83,21 +83,22 @@ making an explicit call into this module at termination. ::
8383
_count = _count + n
8484

8585
def savecounter():
86-
with open("counterfile", "w") as outfile:
87-
outfile.write("%d" % _count)
86+
with open('counterfile', 'w') as outfile:
87+
outfile.write('%d' % _count)
8888

8989
import atexit
90+
9091
atexit.register(savecounter)
9192

9293
Positional and keyword arguments may also be passed to :func:`register` to be
9394
passed along to the registered function when it is called::
9495

9596
def goodbye(name, adjective):
96-
print('Goodbye, %s, it was %s to meet you.' % (name, adjective))
97+
print('Goodbye %s, it was %s to meet you.' % (name, adjective))
9798

9899
import atexit
99-
atexit.register(goodbye, 'Donny', 'nice')
100100

101+
atexit.register(goodbye, 'Donny', 'nice')
101102
# or:
102103
atexit.register(goodbye, adjective='nice', name='Donny')
103104

@@ -107,6 +108,6 @@ Usage as a :term:`decorator`::
107108

108109
@atexit.register
109110
def goodbye():
110-
print("You are now leaving the Python sector.")
111+
print('You are now leaving the Python sector.')
111112

112113
This only works with functions that can be called without arguments.

0 commit comments

Comments
 (0)