Message318407
.2f produces a string representation of a float rounded up to 2 significant digits.
>>> print ("{:.2f}".format(1.891))
1.89
However, it does not respect locale. There is no counterpart of 'f' that would respect locale. There is 'n', but because it follows the rules of 'g', in many cases it returns a different number of significant digits.
>>> print ("{:.2n}".format(1.891))
1.9
In all my uses of formatted float printing, I need to produce floats that are rounded to have the same number of significant digits. I _presume_ this generalizes to the majority people, and the use of 'f' option is much more widespread than the use of 'g'. If this is the case, then a locale-friendly counterpart of 'f' would be very useful. |
|
Date |
User |
Action |
Args |
2018-06-01 12:42:33 | Jakub Szewczyk | set | recipients:
+ Jakub Szewczyk, eric.smith |
2018-06-01 12:42:33 | Jakub Szewczyk | set | messageid: <1527856953.25.0.682650639539.issue33731@psf.upfronthosting.co.za> |
2018-06-01 12:42:33 | Jakub Szewczyk | link | issue33731 messages |
2018-06-01 12:42:33 | Jakub Szewczyk | create | |
|