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
344d26c7
Commit
344d26c7
authored
Apr 10, 2011
by
Ross Lagerwall
Browse files
Options
Browse Files
Download
Plain Diff
Merge with 3.2
parents
dd97fbb2
810b94a3
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 @
344d26c7
...
...
@@ -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 @
344d26c7
...
...
@@ -466,6 +466,11 @@ C-API
- PY_PATCHLEVEL_REVISION has been removed, since it'
s
meaningless
with
Mercurial
.
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