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 correctly, ie. CRLF
for Windows instead of LF for *nix.

For those interested, here's some working code in Windows +
ActivePython:

==========
import glob
    
#activate.tmpl contains the stuff I want to append to each file
f = open("activate.tmpl", "r")
template = "\n\n" + f.read()
f.close()

for frm in glob.glob('*.frm'):
        f = open(frm, "r+")
        content = f.read()
        if 'Form_Activate' not in content:
                f.seek(0,2)
                f.write(template)
        f.close()
==========
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to