This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients John Belmonte, eric.smith, mark.dickinson, serhiy.storchaka, steven.daprano
Date 2021-12-06.19:03:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1638817415.88.0.383066016743.issue45995@roundup.psfhosted.org>
In-reply-to
Content
I'd support having this functionality available for `format` and for f-strings. (As Steven says, changing %-formatting doesn't seem viable.) It really _is_ awkward to do this in any other way, and I'm reliably informed that normal people don't expect to see negative zeros in formatted numeric output.

It did take me a few minutes to get my head around the idea that `f"{-0.01:+.1f}"` would return `"+0.0"` rather than `"-0.0"` or `" 0.0"` or just plain `"0.0"` under this proposal, but I agree that it seems like the only thing that can be consistent and make sense.

I'm not 100% convinced by the particular spelling proposed, but I don't have anything better to suggest. If C++ might be going with a "z", would it make sense to do the same for Python?

I don't forsee any implementation difficulties for float and complex types. For Decimal, we'd need to "own" the string formatting, taking that responsibility away from mpdecimal, but there are already other reasons to do that. Once we've done that, again the implementation doesn't seem onerous.
History
Date User Action Args
2021-12-06 19:03:35mark.dickinsonsetrecipients: + mark.dickinson, eric.smith, steven.daprano, serhiy.storchaka, John Belmonte
2021-12-06 19:03:35mark.dickinsonsetmessageid: <1638817415.88.0.383066016743.issue45995@roundup.psfhosted.org>
2021-12-06 19:03:35mark.dickinsonlinkissue45995 messages
2021-12-06 19:03:35mark.dickinsoncreate