simultaneous reading and writing a textfile

2006-05-16 Thread Marco Herrn
Hi, I have a text file with some lines in it. Now I want to iterate over this file and exchange some lines with some others. I tried this approach: try: myfile= file('myfile', 'r+') while 1: line= myfile.readline() if not line: break l= li

Re: simultaneous reading and writing a textfile

2006-05-17 Thread Marco Herrn
On 2006-05-16, Peter Otten <[EMAIL PROTECTED]> wrote: >> Now how can I achieve, what I want? Really exchange one line with >> another, regardless of their length. Is this possible? If this is not >> possible, then what would be the best approach to do this? > > A file is exposed as a sequence of by