[Python-ideas] Making datetime __str__ and isoformat more consistent

MRAB python at mrabarnett.plus.com
Fri Nov 1 21:37:23 CET 2013


On 01/11/2013 19:49, Ethan Furman wrote:
> On 11/01/2013 11:15 AM, Skip Montanaro wrote:
>> http://bugs.python.org/issue19475
>>
>> Do others agree with me that consistency in this situation is better than
>> the current behavior?
>
> I haven't seen the arguments in favor of this awkward behavior, so I may change my mind, but at the moment I would
> certainly argue for consistency: either emit microseconds in __str__ or ignore remaining microseconds or ignore a
> trailing %f (or all three ;) .
>
Suppose there were, say, 900000 microseconds, i.e. 0.9 seconds?

If the microseconds aren't shown by __str__, should it truncate or
round?

When parsing and there's no %f, should it ignore the microseconds, thus
effectively truncating, or parse and round if necessary?



More information about the Python-ideas mailing list