Am Montag, den 22.08.2005, 09:30 +0200 schrieb Johan Geldenhuys:
> Hi all,
> I want to write to a text file with a timestamp, but I want to newest
> entry at the top. So I want to insert the next entry to the file at
> the beginning.
> I can create and append to a file and then the latest entry is at the
> bottom.
> Any ideas how this is done please?
Well, difficult. Depending upon your needs, you can either copy the
whole file, adding the timestamp at the the top, and rename it
afterwards. Expensive to do. Or if you have to add more timestamps, you
need to store it in some other "data structure", and export a log file
on demand.

Other "data structure" might be a SQL database, a directory full of
small entry files, or one file with a reversed flow.

Basically files (in most OS environments) can only be appended to.

Andreas

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to