Python question
Steven W. Orr
steveo at syslang.net
Tue Jan 13 21:17:45 EST 2009
On Tuesday, Jan 13th 2009 at 14:44 -0000, quoth Thomas Charron:
=>On Tue, Jan 13, 2009 at 12:45 PM, John Abreau <jabr at gapps.blu.org> wrote:
=>> On Tue, Jan 13, 2009 at 10:41 AM, Paul Lussier <p.lussier at comcast.net> wrote:
=>>> "Thomas Charron" <twaffle at gmail.com> writes:
=>>>> Example:
=>>>>>>> strftime("HH:MM:SS ", localtime())
=>>>> '14:17:15'
=>>> Ah, I see. So, if I do this:
=>>> >>> begin = time.time()
=>>> [... long wait here ... ]
=>>> >>> end = time.time()
=>>> >>> time.strftime("%H:%M:%S", time.localtime(end - begin))
=>>> '19:16:07'
=>>> so, the MM:SS are correct, but the 19 for hours is incorrect. It
=>>> should be 00, because "long wait here" was 16:07.
=>> Um, that's completely meaningless -- "end - begin" is not a clock
=>> value, it's the number of seconds that "long wait here" took.
=>> Since it's not a clock value, it makes no sense to use it as
=>> a parameter to time.localtime().
=>
=> Well, it makes sense if you want to use the time formatting
=>capabilities, and just ignore the fact that it thinks it's 1969. :-D
=>But as we've seen, doesn't work to well.
=>
=> I'm actually reading about the datetime classes which Python has
=>which include 'timedelta' classes. It gets it half way there, it will
=>sort out the days, but the hours/minutes would still need to be
=>computed.
Umm, you do have access to datetime.datetime.datetime.year, month, day,
hour, minute, second, microsecond. No need for strftime that I can see.
--
Time flies like the wind. Fruit flies like a banana. Stranger things have .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net
More information about the gnhlug-discuss
mailing list