[issue30302] Improve .__repr__ implementation for datetime.timedelta

STINNER Victor report at bugs.python.org
Thu Jun 29 09:50:06 EDT 2017


STINNER Victor added the comment:

> Between datetime.timedelta(0) and datetime.timedelta(seconds=0), I am ambivalent but I prefer the latter for consistency with the other repr.

I read your latest PR. Now I don't like seconds=0 anymore. I would prefer a datetime.timedelta(0) special case.

In the Python implementation, add:

if not args:
   args.append('0')

and remove the "not days and not microseconds" special case.

datetime.timedelta(0) was always valid, and IMHO it's explicitly enough.

I'm also ok with "datetime.timedelta()" alone, since it was also always accepted and is also well defined.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30302>
_______________________________________


More information about the Python-bugs-list mailing list