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

Skip Montanaro skip at pobox.com
Fri Nov 1 21:29:10 CET 2013


> 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 ;) .

Thanks for the response. I relented after seeing comments from Guido
and Tim. It is highly unlikely that I'd be able to sway the major
devs. Modifying __str__ is a complete non-starter, and Guido pushed
back a bit on the notion of making isoformat() include microseconds.
(He suggested maybe adding an "include microseconds" flag, which I
think would be as bad as the current behavior.

I will preformat my datetime objects in code that writes them out so I
avoid the automatic stringification done by the csv module.

Skip


More information about the Python-ideas mailing list