mirror of
https://github.com/django/django.git
synced 2025-03-26 01:00:46 +00:00
[1.5.x] Fixed #20604 - Fixed file example in docs.
Thanks Chris Lasher for the report. Backport of a1122e14a6 from master
This commit is contained in:
parent
e65f0c2559
commit
e411e99312
@ -85,9 +85,9 @@ The following approach may be used to close files automatically::
|
|||||||
|
|
||||||
# Create a Python file object using open() and the with statement
|
# Create a Python file object using open() and the with statement
|
||||||
>>> with open('/tmp/hello.world', 'w') as f:
|
>>> with open('/tmp/hello.world', 'w') as f:
|
||||||
>>> myfile = File(f)
|
... myfile = File(f)
|
||||||
>>> for line in myfile:
|
... myfile.write('Hello World')
|
||||||
>>> print line
|
...
|
||||||
>>> myfile.closed
|
>>> myfile.closed
|
||||||
True
|
True
|
||||||
>>> f.closed
|
>>> f.closed
|
||||||
|
Loading…
x
Reference in New Issue
Block a user