Re: [newbie] Read file, and append?

2007-12-27 Thread Gilles Ganault
On Wed, 26 Dec 2007 14:33:15 -0800, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: >Works for me, as long as one uses a seek() call when switching >between read and write... Thanks, Dennis. Worked :-) I just changed the access mode from binary to text so that Python handles the EOL character correct

Re: Read file, and append?

2007-12-26 Thread John Machin
On Dec 27, 9:04 am, Gilles Ganault <[EMAIL PROTECTED]> wrote: > On Tue, 25 Dec 2007 13:27:09 -0800, Dennis Lee Bieber > > <[EMAIL PROTECTED]> wrote: > >Ignoring the question of the proper I/O mode, I believe the I/O > >system MAY require one to perform a seek() when switching from read to > >write

Re: [newbie] Read file, and append?

2007-12-26 Thread Gilles Ganault
On Tue, 25 Dec 2007 13:27:09 -0800, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: >Ignoring the question of the proper I/O mode, I believe the I/O >system MAY require one to perform a seek() when switching from read to >write and vice versa... I thought about this, but I don't understand why I woul

Re: [newbie] Read file, and append?

2007-12-25 Thread Gilles Ganault
On Tue, 25 Dec 2007 01:14:37 -0800, Gary Herron <[EMAIL PROTECTED]> wrote: >Here's what I'd end up with. (This is untested.) Thanks a lot. It worked. I didn't suspect there could be so many errors in such a small sript :-D -- http://mail.python.org/mailman/listinfo/python-list

Re: [newbie] Read file, and append?

2007-12-25 Thread Gary Herron
Gilles Ganault wrote: > Hello > > I'd just like to open each file in a directory with a given extension, > read it to search for a pattern, and, if not found, append data to > this file. The following doesn't work: > > == > import glob,re > > f = open("activate.tmpl", "r") > template = f.

[newbie] Read file, and append?

2007-12-25 Thread Gilles Ganault
Hello I'd just like to open each file in a directory with a given extension, read it to search for a pattern, and, if not found, append data to this file. The following doesn't work: == import glob,re f = open("activate.tmpl", "r") template = f.read() template = "\r\n" + template f.clos