[Tutor] formatting datetime.timedelta to "HH:MM:SS"

Jignesh Sutar jsutar at gmail.com
Wed Dec 11 22:32:34 CET 2013


>
> Yes, because exe-time is not a ate, a point in time, but a time delta (a
> difference), thus does not hold the same attributes. Write out dir() on
> 'now' and on 'exe_time' to get more info. [dir() tells you about what info
> an object knows, and what methods it understands).]


Thanks Denis, that's very useful. I guess I was trying to deduce the same
information from the documentation but dir is a good way of double checking.


> This is a correct and general solution. Maybe worth being built-in, in
> fact, in my view.


Thanks for confirming. Yes, exactly, I was hoping to achieve this without
all the modulus calculations.

Cheers,
Jignesh



On 11 December 2013 21:18, spir <denis.spir at gmail.com> wrote:

> On 12/11/2013 06:40 PM, Jignesh Sutar wrote:
>
>> c = b-a
>> print "%s days, %.2dh: %.2dm: %.2ds" %
>> (c.days,c.seconds//3600,(c.seconds//60)%60, c.seconds%60)
>>
>
> This is a correct and general solution. Maybe worth being built-in, in
> fact, in my view.
>
> Denis
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20131211/5db37bf7/attachment.html>


More information about the Tutor mailing list