In article <[email protected]>, Steven D'Aprano <[email protected]> wrote:
> On Thu, 27 Mar 2014 08:52:24 -0400, Roy Smith wrote: > > > In article <[email protected]>, > > Chris Angelico <[email protected]> wrote: > >> It's not "equally braindead", it follows a simple and logical rule: > >> Only the day portion is negative. > > > > Simple and logical, yes. But also entirely braindead. > > Do you think it is "braindead" for __str__ to return something which > follows the internal representation of the object? Yes. The whole idea of OOD is to decouple internal representation from external behavior. > > Give ma a real-life situation where you would want such behavior. > > Easy -- I'm debugging timedelta routines, and I want to easily see that > the timedeltas calculated match what I expect them to be when I print > them. The quickest, easiest and simplest way is for str(timedelta) to > follow the internal representation. That's what __repr__() is for. > Oh look, that's exactly what the docs say: > > "String representations of timedelta objects are normalized similarly to > their internal representation. This leads to somewhat unusual results for > negative timedeltas." Yes, I know that's what the docs say. That's why it's not an implementation bug. It's a design bug :-) -- https://mail.python.org/mailman/listinfo/python-list
