Q: finding distance between 2 time's

John Machin sjmachin at lexicon.net
Sat May 30 19:36:09 EDT 2009


On May 30, 7:33 pm, mar... at hvidberg.net wrote:
> I made this little script (below) to look througt a dir to see if
> there are any files newer than .e.g. 1 hour.
> I have the loop through the dir working and can retreive file time as
> well as present time.
> both time variables are in the format returned by time.localtime()
>
> My question:
> How do I find the difference between such two time variables, to
> calculate the 'age' of the file?

http://en.wikipedia.org/wiki/Subtraction

This technique in well worth learning, as it can be applied in many
real-world situations, sometimes not even requiring a computer. For
example:

The letter was postmarked on the 18th of May; it was delivered on the
29th of May; how many days was it in transit? You give a $10 note for
an article priced at $6.35; how much change should you get?

HTH,
John



More information about the Python-list mailing list