[issue30302] Improve .__repr__ implementation for datetime.datetime.timedelta

Utkarsh Upadhyay report at bugs.python.org
Sun May 7 15:57:27 EDT 2017


New submission from Utkarsh Upadhyay:

Currently, the default implementation of datetime.datetime.__repr__ (the default output string produced at the console/IPython) gives a rather cryptic output:

from datetime import datetime as D
D.fromtimestamp(1390953543.1) - D.fromtimestamp(1121871596)
# datetime.timedelta(3114, 28747, 100000)

For the uninitiated, it is not obvious that the numeric values here are `days`, `seconds` and `microsecond` respectively.

Would there be any pushback against changing this to:

# datetime.timedelta(days=3114, seconds=28747, microseconds=100000)

?

----------
components: Library (Lib)
messages: 293212
nosy: musically_ut
priority: normal
severity: normal
status: open
title: Improve .__repr__ implementation for datetime.datetime.timedelta
type: enhancement
versions: Python 2.7, Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7

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


More information about the Python-bugs-list mailing list