This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients belopolsky, martin.panter, musically_ut, r.david.murray, serhiy.storchaka, tim.peters, vstinner
Date 2017-07-25.22:00:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Do you think that repr(datetime.timedelta) should be documented in the Porting section of What's New in 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.
Date User Action Args
2017-07-25 22:00:45vstinnersetrecipients: + vstinner, tim.peters, belopolsky, r.david.murray, martin.panter, serhiy.storchaka, musically_ut
2017-07-25 22:00:45vstinnersetmessageid: <>
2017-07-25 22:00:45vstinnerlinkissue30302 messages
2017-07-25 22:00:45vstinnercreate