[issue41260] datetime: strftime method takes different keyword argument: fmt (pure) or format (C)

Paul Ganssle report at bugs.python.org
Thu Jul 9 15:06:30 EDT 2020


Paul Ganssle <p.ganssle at gmail.com> added the comment:

I think a positional-only argument would be the best option if we could do it, but it would be a backwards-incompatible change and it's probably not worth the hassle.

If anyone is using the keyword argument, they're probably using `format=` rather than `fmt=`, since it's pretty rare for anyone to use the pure python version of datetime. PyPy uses it, but I think they tend to aim for consistency with the C API of CPython, and it seems like they already patch s/fmt/format/ themselves: https://foss.heptapod.net/pypy/pypy/-/blob/branch/default/lib_pypy/datetime.py#L781

If anyone wants to make a PR I think we can fix this for 3.10, though unfortunately because it is an API change it can't be backported. I think in typeshed they can safely change from `fmt` to `format` even today (which would almost certainly be more accurate to end user use cases).

----------
nosy:  -rkm
stage:  -> needs patch

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41260>
_______________________________________


More information about the Python-bugs-list mailing list