STINNER Victor added the comment:

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.

----------

_______________________________________
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