Removing last line while appending to file
Tim Wegener
twegener at fastmail.fm
Wed Apr 30 01:56:08 EDT 2003
Hi,
Is there a simple way to remove the last line (or arbitrary trailing
portion) of a file, when appending to it?
I want to write a log file in xml, which requires root elements around
all the log data. This means that when I want to append to the log I
must first remove the trailing </log> element.
I have tried using file.seek() and file.tell() to no avail. I would
prefer not to parse the entire file each time I want to simply append an
entry.
Thanks,
Tim
More information about the Python-list
mailing list