Python question
    Thomas Charron 
    twaffle at gmail.com
       
    Tue Jan 13 14:44:00 EST 2009
    
    
  
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.
-- 
-- Thomas
    
    
More information about the gnhlug-discuss
mailing list