<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Dec 20, 2015 at 9:00 PM, Guido van Rossum <span dir="ltr"><<a href="mailto:guido@python.org" target="_blank">guido@python.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="gmail_extra"><div class="gmail_quote"><span class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>but I would really like to see a change in the repr of negative timedeltas:</div><div><br></div><div><div>>>> timedelta(minutes=-1)</div><div>datetime.timedelta(-1, 86340)<br><br></div></div></div></div></div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_extra">And str() is not much better:</div><div class="gmail_extra"><br></div><div class="gmail_extra">>>> print(timedelta(minutes=-1))</div><div class="gmail_extra">-1 day, <span class="" tabindex="0"><span class="">23:59:00</span></span></div><div class="gmail_extra"><br></div>The above does not qualify as a human readable representation IMO.</div></div>
</blockquote></span></div><br></div><div class="gmail_extra">I'm sure that one often catches people by surprise. However, I don't think we can fix that one without also fixing the values of the attributes </div></blockquote><div><br></div><div>I don't see why we have to change td.days for say td = timedelta(minutes=-1) if we change its repr to "timedelta(minutes=-1)". For me an important invariant is td == eval(repr(td)) which will be preserved.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="gmail_extra">-- in that example days is -1 and seconds is 86340 (which will *also* catch people by surprise). And changing that would be much, much harder for backwards compatibility reasons-- we'd have to set days to 0 and seconds to -60, and suddenly we have a much murkier invariant, instead of the crisp<br><br></div><div class="gmail_extra"> 0 <= microseconds < 1000000<br></div><div class="gmail_extra"> 0 <= seconds < 60<br><br>(There is no such invariant for days -- they hold the sign bit.)<br><br>In essence, you'd have to look at all three attributes to figure out on which side of 0 is was (or think of the right way to do it, which is to compare to timedelta(0)). I might still go for it, if it wasn't too late by over a decade (as Tim says).</div></blockquote></div><br><br></div></div>