[Python-Dev] datetime nanosecond support (ctd?)

MRAB python at mrabarnett.plus.com
Thu Dec 11 22:00:12 CET 2014


On 2014-12-11 18:33, Skip Montanaro wrote:
> On Thu, Dec 11, 2014 at 11:58 AM, Matthieu Bec <mdcb808 at gmail.com> wrote:
>> ...or keep using "%f" if acceptable...
>
> That might be a problem. While it will probably work most of the time,
> there are likely to be situations where the caller assumes it
> generates a six-digit string. I did a little poking around. It seems
> like "%N" isn't used.
>
Could the number of digits be specified? You could have "%9f" for
nanoseconds, "%3f" for milliseconds, etc. The default would be 6
microseconds for backwards compatibility.

Maybe, also, strptime could support "%*f" to gobble as many digits as
are available.


More information about the Python-Dev mailing list