Re: inserting into a file

2006-09-11 Thread Larry Bates
Sai Krishna M wrote: > I want to insert a string in a file after a particular line. > > I thought of using seek() function but on opening the file in append > mode the seek value is undone. > One crude idea i had was to read the file in a list and insert the > string correspondingly. > > Is there

Re: inserting into a file

2006-09-11 Thread Fredrik Lundh
"Sai Krishna M" wrote: > One crude idea i had was to read the file in a list and insert the > string correspondingly. file systems usually don't support insertion and deletion, so if you want to move things around, you have to do that yourself. reading and writing lists (using readlines/writeli

inserting into a file

2006-09-11 Thread Sai Krishna M
I want to insert a string in a file after a particular line. I thought of using seek() function but on opening the file in append mode the seek value is undone. One crude idea i had was to read the file in a list and insert the string correspondingly. Is there any other way to do this? Please hel