[Python-Dev] datetime.timedelta total_microseconds

Terry Reedy tjreedy at udel.edu
Tue Feb 26 22:15:17 EST 2019


On 2/26/2019 7:03 PM, Chris Barker via Python-Dev wrote:

> So: it would be good to provide a correct, simple,  intuitive, and 
> discoverable way to do that.
> 
> timedelta.total_seconds()

To me, total_x implies that there is a summation of multiple timedeltas, 
and there is not.  So not intuitive to me.  (Neither us current obscure 
option).  It is also not obvious is answer is rounded to nearest second 
or not.

> 
> So at most, we could have:
> 
> .total_microseconds()
> .total_seconds()
> .total_minutes()
> .total_hours()
> .total_days()
> .total_weeks()

I am also not enthusiastic about multiple methods doing essentially the 
same thing.  I might prefer one method, .convert? with an argument 
specifying the conversion unit, 'microseconds', 'seconds', ... . I think 
this is in python-ideas territory.



-- 
Terry Jan Reedy




More information about the Python-Dev mailing list