Re: How to use writelines to append new lines to an existing file

2005-09-22 Thread Max Erickson
Nico Grubert <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > Hi there, > > I would like to open an existing file that contains some lines of > text in order to append a new line at the end of the content. > > My first try was: > > >>> f = open('/tmp/myfile', 'w') #create new file for wr

Re: How to use writelines to append new lines to an existing file

2005-09-22 Thread Tom Brown
On Thursday 22 September 2005 05:52, Nico Grubert wrote: > Does f = open('/tmp/myfile', 'w') overwrite the existing file or > does f.writelines('456') replace the first line in the existing file? Here's an excerpt from open.__doc__ The mode can be 'r', 'w' or 'a' for reading (default), w

Re: How to use writelines to append new lines to an existing file

2005-09-22 Thread Grigoris Tsolakidis
Use file = open(open('/tmp/myfile', 'a')) the second time when you want to append line "Nico Grubert" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi there, > > I would like to open an existing file that contains some lines of text in > order to append a new line at the end of t

How to use writelines to append new lines to an existing file

2005-09-22 Thread Nico Grubert
Hi there, I would like to open an existing file that contains some lines of text in order to append a new line at the end of the content. My first try was: >>> f = open('/tmp/myfile', 'w') #create new file for writing >>> f.writelines('123') #write first line >>> f.close() >>> f