Confused.

Alex Martelli aleaxit at yahoo.com
Sat Nov 11 10:52:30 EST 2000


"Syver Enstad" <syver.enstad at sensewave.com> wrote in message
news:8ujmg5$t3j$1 at troll.powertech.no...
>
> <gbreed at cix.compulink.co.uk> wrote in message
> news:8ubfv8$nth$1 at plutonium.compulink.co.uk...
> > Is that what you wanted, then?  Here's how I'd do it:
> >
> > import pywintypes, time
> > comtime = pywintypes.Time(time.time())
>
> > To make the two methods equivalent, take float(comtime)
> Sorry, I don't understand what you're saying in the line above. Which two
> methods?

The approach you proposed was:

> def MakeComTime(ctime):
>     return (ctime / 86400.0) + 25569.0

gbreed's alternative suggestion was:

> > import pywintypes, time
> > comtime = pywintypes.Time(time.time())

These are no doubt the two alternatives he was referring
to as "the two methods" in his sentence:

> > To make the two methods equivalent, take float(comtime)


> Take float(comtime) I don't follow you.

Consider, for example:

>>> ctime=time.time()
>>> (ctime / 86400.0) + 25569.0
36841.659544907408
>>> pywintypes.Time(ctime)
<time object at 0104C930>
>>> float(pywintypes.Time(ctime))
36841.701203703706
>>>

Your formula produces a float; the pywintypes.Time
function produces a time-object insteat.  Taking the
float() of that time-objects yields a float, that is the
rough equivalent of what your formula produces (I
don't know which is the more accurate, considering
that fraction-of-a-second difference).


Alex






More information about the Python-list mailing list