[issue30302] Improve .__repr__ implementation for datetime.timedelta

Utkarsh Upadhyay report at bugs.python.org
Sun May 21 14:09:33 EDT 2017


Utkarsh Upadhyay added the comment:

So we are okay with

datetime.timedelta(minutes=-1)
# -datetime.timedelta(seconds=60)

and

datetime.timedelta(minutes=-1).seconds
# 86340

datetime.timedelta(minutes=-1).days
# -1

?

Perhaps I'm reading this incorrectly:

"If the repr() shows different numbers than the attributes things are worse than now." ~ Guido, https://marc.info/?l=python-dev&m=145066934224955&w=2

Maybe he was only talking about:

datetime.timedelta(minutes=-1)
# datetime.timedelta(minutes=-1)

but I would like a second opinion on it. :)

Also, I'll just drop the description of .repr from the .RST documentation because it is not to be relied on anyway. Any objections to that?

~
ut

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30302>
_______________________________________


More information about the Python-bugs-list mailing list