[Tutor] problem with time module
tim.peters at gmail.com
Mon Aug 16 19:35:02 CEST 2004
> Please forgive me for persisting here, but mktime(t) is not the inverse
> function of localtime() in the same precise way that pow(n,2) and sqrt
> (n) are inverses of each other (for n >= 0):
> >>> from math import sqrt
> >>> n = 78.56
> >>> print pow(sqrt(n),2)
> >>> print sqrt(pow(n,2))
> Thus my misunderstanding of the doc.
>>> from time import mktime as m, localtime as lt
They're exact inverses, so long as localtime's argument is an integral
value (has no fractional seconds). Because of floating-point rounding
errors, they're closer to being exact inverses than sqrt and pow(_,
>>> from math import sqrt
>>> pow(sqrt(2), 2)
> And thanks very much for your assistance, Mr. Peters.
My father died a long time ago -- I'm just Uncle Timmy <wink>.
More information about the Tutor