Utkarsh Upadhyay added the comment:

> This was discussed fairly recently: 
> <https://marc.info/?i=captjjmrbxpvyquyxshbc1j13m_h5or67cnbkrkysw4ef6rq...@mail.gmail.com>
That thread went deep and culminated here, as far as I can tell: 
https://marc.info/?l=python-dev&m=145077422417470&w=2 (I may not have explored 
all the branches, though.)

So there indeed seems to be general agreement about changing this. It was 
heartening to know that I wasn't the only one to stumble. \o/

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

No, the doc-string is as uninformative as then, as far as I can tell:

  In [178]: datetime.timedelta?
  Init signature: datetime.timedelta(self, /, *args, **kwargs)
  Docstring:      Difference between two datetime values.
  File:           ~/miniconda3/lib/python3.5/datetime.py
  Type:           type 

I'll investigate what documentation for other functions looks like and see if I 
can come up with something better. The exact documentation would be best 
discussed over diffs on Github.

Then there is the issue of repr being explicitly documented, as you had pointed 
out on the Github issue. Guido thinks that any breakage is _unlikely_ but 
"asked around" here: https://marc.info/?l=python-dev&m=145065347022557&w=2

As far as I can tell, he didn't see an explicit response.

> 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.

Personally, I don't see a big problem either way but having datetime.timedelta 
in the repr feels reassuring to me that I have the 'right' type instead of some 
other 'timedelta' from a non-stdlib module (e.g. moments or pandas).


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

This sounds reasonable. I'll make this change and add corresponding tests.

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

I'm not sure there was consensus about this; if I understand correctly, Guido 
thinks that it is important that the repr return what the attributes hold: 
https://marc.info/?l=python-dev&m=145066934224955&w=2

----------

_______________________________________
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