Managing Files File code example opens file in write-mode, should open in read-mode
|Reported by:||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
In the second code example in the Managing Files documentation on the File object, the file /tmp/hello.world is shown as being opened in write-mode, but it should actually be opened in read mode. Write-mode would destroy the contents of the file.
In other words, please change this
# Create a Python file object using open() and the with statement >>> with open('/tmp/hello.world', 'w') as f: >>> myfile = File(f) ...
# Create a Python file object using open() and the with statement >>> with open('/tmp/hello.world') as f: >>> myfile = File(f) ...