Author haypo
Recipients belopolsky, haypo, martin.panter, musically_ut, r.david.murray, serhiy.storchaka, tim.peters
Date 2017-07-25.22:00:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1501020045.67.0.995869129042.issue30302@psf.upfronthosting.co.za>
In-reply-to
Content
Do you think that repr(datetime.timedelta) should be documented in the Porting section of What's New in Python 3.7?

https://docs.python.org/dev/whatsnew/3.7.html#porting-to-python-3-7

It was proposed in the middle of the python-dev thread. I have no opinion on that... or just a little -0 vote, if someone is impacted, it should be easy to notice it anymore, no?

--

While we don't have an obvious consensus, I took the responsability of merging Utkarsh Upadhyay's contribution. He wrote that he is interested to pursue the effort by also enhancing the docstring: please, go ahead, write a new PR, I will help you!

It was discussed to rewrite datetime.timedelta: only accept keywords in its constructor, store seconds=60 as minutes=1, etc. The problem is that it's too late to change the design. So I suggest to not waste time on discussing that, but focus the energy on making tiny changes to enhance the implemenatation without risking of breaking the world.

While developers using regulary timedelta knows what means the 3 numbers, it seems clear that the other developers have to check for the documentation. IMHO having to check the documentation is an issue: adding keywords to repr() reduces the need of documentation, and so makes Python more usable.

Sorry about the longer repr(): use str() or write your own formater?

By the way, if you need a formatter working on Python 2.7-3.7:

>>> def format_td(td): return 'timedelta(%s, %s, %s)' % (td.days, td.seconds, td.microseconds)
... 
>>> format_td(datetime.timedelta(seconds=1))
'timedelta(0, 1, 0)'


If someone disagree with my merge, I suggest to reopen a thread on python-dev.
History
Date User Action Args
2017-07-25 22:00:45hayposetrecipients: + haypo, tim.peters, belopolsky, r.david.murray, martin.panter, serhiy.storchaka, musically_ut
2017-07-25 22:00:45hayposetmessageid: <1501020045.67.0.995869129042.issue30302@psf.upfronthosting.co.za>
2017-07-25 22:00:45haypolinkissue30302 messages
2017-07-25 22:00:45haypocreate