Message407857
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. |
|
Date |
User |
Action |
Args |
2021-12-06 19:03:35 | mark.dickinson | set | recipients:
+ mark.dickinson, eric.smith, steven.daprano, serhiy.storchaka, John Belmonte |
2021-12-06 19:03:35 | mark.dickinson | set | messageid: <1638817415.88.0.383066016743.issue45995@roundup.psfhosted.org> |
2021-12-06 19:03:35 | mark.dickinson | link | issue45995 messages |
2021-12-06 19:03:35 | mark.dickinson | create | |
|