Author musically_ut
Recipients belopolsky, martin.panter, musically_ut, serhiy.storchaka
Date 2017-05-08.00:42:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1494204172.4.0.742895511498.issue30302@psf.upfronthosting.co.za>
In-reply-to
Content
> This was discussed fairly recently: <https://marc.info/?i=CAPTjJmrBxpvYQUYXshBC1J13M_h5or67CNBKrkySw4ef6RqDoQ@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
History
Date User Action Args
2017-05-08 00:42:52musically_utsetrecipients: + musically_ut, belopolsky, martin.panter, serhiy.storchaka
2017-05-08 00:42:52musically_utsetmessageid: <1494204172.4.0.742895511498.issue30302@psf.upfronthosting.co.za>
2017-05-08 00:42:52musically_utlinkissue30302 messages
2017-05-08 00:42:50musically_utcreate