Having trouble with file modes

Hendrik van Rooyen mail at microcorp.co.za
Sat Nov 4 06:57:21 CET 2006

 "erikcw" <erikwickstrom at gmail.com> wrote:

> #loop through patterns list and find/replace data
> for o, r in patterns:
>     data = data.replace(o, r)
>     print "Replaced %s with %s" % (o, r)
> f.write(data)
> f.close()
> This results in an empty file.  All of the modes I've tried either
> produce an empty file or append the data onto the end of the file.  How

I would take a hard look at what the find and replace does - it acts as if you
are replacing
*everything*   with   *nothing*....

- Hendrik

More information about the Python-list mailing list