[Tutor] how to write a string into a specific line in a file

andrew clarke mail at ozzmosis.com
Wed Mar 8 12:41:21 CET 2006


On Tue, Mar 07, 2006 at 11:18:27AM -0000, Alan Gauld wrote:

> > I was wondering if it is possible to write a string to a specific line
> > in a file without reading in the whole file in as the below.
> 
> Some languages, such as COBOL and some BASICs etc support 
> random access files, unfortunately Python doesn't (Although I'll be 
> amazed if somebody hasn't cooked up (or is cooking up) a module 
> that does it)

You then go on to mention file.seek().  I thought that seek() provided
"random access", ie. to seek to anywhere at random in a file.  Can you
clarify what you mean by "random access files"?

Regards
Andrew


More information about the Tutor mailing list