append log file

Gerrit Holl gerrit at nl.linux.org
Mon Sep 29 16:23:35 EDT 2003


Tom wrote:
> I have a log file and of course I want to add the new information to the 
> end of that log file. Unfortunately I always delete the old information 
> and only append the current info.

>        LogFile = file(filename, 'w')

You should use 'a' instead of 'w'. 'a' means 'append'. 'w' always means
overwriting the content.

> How can I add the new info without deleting the old info?
> I tried the modes 'a' and 'a+' but they both didn't work. Actually the 
> data was totally unreadable! It was kind of messed up. :-( I don't know why.

What did you try with 'a' exactly? It should work!

Gerrit.

-- 
128. If a man take a woman to wife, but have no intercourse with her,
this woman is no wife to him.
        -- 1780 BC, Hammurabi, Code of Law
--
Asperger Syndroom - een persoonlijke benadering:
	http://people.nl.linux.org/~gerrit/
Het zijn tijden om je zelf met politiek te bemoeien:
	http://www.sp.nl/





More information about the Python-list mailing list