file ops on the fly ?

Alex Martelli aleax at aleax.it
Fri Jul 19 07:49:18 EDT 2002


Shagshag13 wrote:

> hello,
> 
> is it possible (and how) to do "on the fly" reading and updating on file ?

You can open a file for 'r+b' and then call both read and write on it,
moving around with seek and possibly tell.  This is hardly ever useful
on a text file, though.  But I guess much depends on what you mean by
"on the fly" in this context -- maybe the simulation of inplace edits
for text files offered by standard module fileinput is all you need?


Alex




More information about the Python-list mailing list