summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorKrzysiek Karbowiak <krzysztof.karbowiak@interia.pl>2023-10-31 22:06:02 (GMT)
committerGitHub <noreply@github.com>2023-10-31 22:06:02 (GMT)
commit102685c4c8481ec5d9c132fcf06b46057e815969 (patch)
tree1e7d19082bd14fdbd0766e2f9fc39a4fdfee658c /Doc
parent770530679e89b06f33655b34a8c466ed906842fe (diff)
downloadcpython-102685c4c8481ec5d9c132fcf06b46057e815969.zip
cpython-102685c4c8481ec5d9c132fcf06b46057e815969.tar.gz
cpython-102685c4c8481ec5d9c132fcf06b46057e815969.tar.bz2
gh-111282: Fix NamedTemporaryFile example code (GH-111283)
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/tempfile.rst14
1 files changed, 7 insertions, 7 deletions
diff --git a/Doc/library/tempfile.rst b/Doc/library/tempfile.rst
index b2baa54..b68a78e 100644
--- a/Doc/library/tempfile.rst
+++ b/Doc/library/tempfile.rst
@@ -404,13 +404,13 @@ Here are some examples of typical usage of the :mod:`tempfile` module::
# create a temporary file using a context manager
# close the file, use the name to open the file again
- >>> with tempfile.TemporaryFile(delete_on_close=False) as fp:
- ... fp.write(b'Hello world!')
- ... fp.close()
- # the file is closed, but not removed
- # open the file again by using its name
- ... with open(fp.name) as f
- ... f.read()
+ >>> with tempfile.NamedTemporaryFile(delete_on_close=False) as fp:
+ ... fp.write(b'Hello world!')
+ ... fp.close()
+ ... # the file is closed, but not removed
+ ... # open the file again by using its name
+ ... with open(fp.name, mode='rb') as f:
+ ... f.read()
b'Hello world!'
>>>
# file is now removed