Message376053
I looked through a lot of the suggested libraries and they all seemed either too specific to an implementation or didn't fully implement compatibility. So I created Prefixed to prove out the implementation of of an expanded format specification for float would look like.
It implements 3 new format types:
- h: SI Decimal prefix (..., n, μ, m, k, M, G, ...)
- j: IEC Binary prefix (Ki, Mi, Gi, ...)
- J: Shortened IEC Binary prefix (K, M, G, ...)
It also implements a new flag, '!' that will add a space before the prefix.
For now, the math is pretty simple, if you cross a magnitude level it will go to that prefix. So 999 would be '999' and 1000 would be 1k.
I was thinking another format specification option '%' followed by a digit could be used to set the threshold of when to switch, so f'{950.0:%5.2h}' would be '0.95k', but f'{949.0:%5.2h}' would be '949.00'. Was going to think about it a little more before implementing.
I'd appreciate feedback on the library. Issues can be submitted here: https://github.com/Rockhopper-Technologies/prefixed/issues
https://pypi.org/project/prefixed/ |
|
Date |
User |
Action |
Args |
2020-08-29 02:42:33 | aviso | set | recipients:
+ aviso, eric.smith, martin.panter, serhiy.storchaka, desbma, mivade, miserlou2, FlipperPA, Jason Stelzer |
2020-08-29 02:42:33 | aviso | set | messageid: <1598668953.59.0.945291809381.issue31749@roundup.psfhosted.org> |
2020-08-29 02:42:33 | aviso | link | issue31749 messages |
2020-08-29 02:42:33 | aviso | create | |
|