random writing access to a file in Python

Fredrik Lundh fredrik at pythonware.com
Fri Aug 25 18:04:48 EDT 2006


Claudio Grondi wrote:

> I was smart enough to try it first on a very small file wondering what 
> was happening. Python documentation and even Google search after 'random 
> file access in Python' were not helpful as there was no example and no 
> hint available.

one would think that the repeated use of the word "truncate" in the 
documentation for open/file would have provided the necessary hints:

     "'w' for writing (truncating an existing file)"

     "Modes 'r+', 'w+' and 'a+' open the file for updating
     (note that 'w+' truncates the file)"

</F>




More information about the Python-list mailing list