Martin Panter added the comment:

This was discussed fairly recently: 
<https://marc.info/?i=captjjmrbxpvyquyxshbc1j13m_h5or67cnbkrkysw4ef6rq...@mail.gmail.com>.
 There seems to be a bit of support for changing this. It is not a bug fix, so 
has to go into the next release, now 3.7.

I disagree that the positional timedelta parameters are well-known.

The built-in help was also discussed in that thread. I don’t think it got fixed 
yet, did it?

The datetime class represents absolute dates. It is nonsense to specify a date 
without a year. Timedelta is different, because time is measured with different 
units. The first parameter (days) is surprising considering most other Python 
APIs (sleep etc) deal with seconds.

The size of the repr could be reduced a bit by dropping the module name: 
datetime.timedelta vs just timedelta. Although that would be inconsistent with 
the other classes; I’m not sure about this.

Other improvements that I would like to see:

1. Drop leading zeros: timedelta(seconds=60) rather than timedelta(days=0, 
seconds=60). This would also help reduce the size.

2. Factor out the negative sign: -timedelta(seconds=60) rather than 
timedelta(days=-1, seconds=86340).

----------
nosy: +martin.panter
title: Improve .__repr__ implementation for datetime.datetime.timedelta -> 
Improve .__repr__ implementation for datetime.timedelta
versions:  -Python 2.7, Python 3.3, Python 3.4, Python 3.5, Python 3.6

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue30302>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to