why no time() + timedelta() ?

Tim Peters tim.peters at gmail.com
Thu Jan 20 11:50:14 EST 2005


[josh]
> Why can't timedelta arithmetic be done on time objects?

Obviously, because it's not implemented <wink>.

> (e.g. datetime.time(5)-datetime.timedelta(microseconds=3)
>
> Nonzero "days" of the timedelta could either be ignored, or
> trigger an exception.

And if the result is less than 0, or >= 24 hours, it could raise
OverflowError, or wrap around mod 24*60*60*1000000 microseconds, and
so on.  There are so many arbitrary endcases that no agreement could
be reached on what they "should" do.  So it's not supported at all. 
In contrast, it was much easier to reach consensus on what datetime
arithmetic should do, so that was supported.



More information about the Python-list mailing list