[issue46614] Add option to output UTC datetimes as "Z" in `.isoformat()`

Matt Wozniski report at bugs.python.org
Sun Apr 3 21:30:42 EDT 2022


Matt Wozniski <godlygeek at gmail.com> added the comment:

> My main hesitation with this name is that I suspect users may think that `use_utc_designator` means that they *unconditionally* want to use `Z` — without reading the documentation (which we can assume 99% of users won't do)

I was thinking along similar lines when I used `use_utc_designator` in the PR, but I drew a different conclusion. I was thinking that the name `use_utc_designator` is sufficiently abstruse that no one would even be able to guess that it's referring to "Z" without actually reading the documentation for the parameter. In particular, I worry that `zulu=True` or `allow_Z=True` might lead people to make the mistake of thinking that they'll always get "Z" instead of "+00:00".

> A name like `utc_as_z` is definitely less... elegant, but conveys the concept a bit more clearly.

This would definitely be more memorable and more approachable. If we stick with making it conditional on `tzname() == "UTC"`, I definitely think we want to have "utc" in the name of the parameter, and `utc_as_z` satisfies that.

`utc_as_z` seems reasonable to me. Let me know if you'd like me to update the PR.

----------

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


More information about the Python-bugs-list mailing list