Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
810b94a3
Commit
810b94a3
authored
Apr 10, 2011
by
Ross Lagerwall
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #11818: Fix tempfile examples for Python 3.
parent
dbb677a8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
5 deletions
+10
-5
Doc/library/tempfile.rst
Doc/library/tempfile.rst
+5
-5
Misc/NEWS
Misc/NEWS
+5
-0
No files found.
Doc/library/tempfile.rst
View file @
810b94a3
...
...
@@ -242,26 +242,26 @@ Here are some examples of typical usage of the :mod:`tempfile` module::
# create a temporary file and write some data to it
>>> fp = tempfile.TemporaryFile()
>>> fp.write('Hello world!')
>>> fp.write(
b
'Hello world!')
# read data from file
>>> fp.seek(0)
>>> fp.read()
'Hello world!'
b
'Hello world!'
# close the file, it will be removed
>>> fp.close()
# create a temporary file using a context manager
>>> with tempfile.TemporaryFile() as fp:
... fp.write('Hello world!')
... fp.write(
b
'Hello world!')
... fp.seek(0)
... fp.read()
'Hello world!'
b
'Hello world!'
>>>
# file is now closed and removed
# create a temporary directory using the context manager
>>> with tempfile.TemporaryDirectory() as tmpdirname:
... print
'created temporary directory', tmpdirname
... print
('created temporary directory', tmpdirname)
>>>
# directory and contents have been removed
Misc/NEWS
View file @
810b94a3
...
...
@@ -257,6 +257,11 @@ Tests
- Issue #10826: Prevent sporadic failure in test_subprocess on Solaris due
to open door files.
Documentation
-------------
- Issue #11818: Fix tempfile examples for Python 3.
What'
s
New
in
Python
3.2
?
=========================
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment