Read from, then write to a file without closing first???
Miki Tebeka
miki.tebeka at zoran.com
Thu Jan 8 08:40:09 EST 2004
Hello Amy,
> I am looking to make this code a little "nicer"... any suggestions???
> I want to do a "read+" where I would be able to first read the contents of
> the file... then either close the file out or write to the file without
> appending. I want to overwrite the content.
def check(file, msg):
if open(file).read() != msg:
open(file, "w").write(msg)
HTH.
Miki
More information about the Python-list
mailing list