[Tutor] How to write lines in a text file (GUI)

Dave Angel d at davea.name
Tue Nov 29 23:12:55 CET 2011


On 11/29/2011 02:24 PM, Mic wrote:
>
>
> <SNIP>

> Actually, I nearly know how do to solve this problem. I just have one 
> problem. Can I use writeline() to write text into line 3 or line 5 for 
> example?
> Say that I want to write the text "hi" into line five of a text file, 
> can I do this using writeline(), if so, how ?
>

This is why you should stick to one thread for one problem.  Read my 
reply on your original thread.  You cannot safely update intermediate 
lines in a text file unless you're positive they're the same length.  
And even then, using seek() to position yourself is fraught with 
problems, especially if you have to work on Windows.

Either use a binary file, or write the whole file out each time.

-- 

DaveA



More information about the Tutor mailing list