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 aviso
Recipients FlipperPA, Jason Stelzer, aviso, desbma, eric.smith, martin.panter, miserlou2, mivade, serhiy.storchaka
Date 2020-08-29.02:42:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1598668953.59.0.945291809381.issue31749@roundup.psfhosted.org>
In-reply-to
Content
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/
History
Date User Action Args
2020-08-29 02:42:33avisosetrecipients: + aviso, eric.smith, martin.panter, serhiy.storchaka, desbma, mivade, miserlou2, FlipperPA, Jason Stelzer
2020-08-29 02:42:33avisosetmessageid: <1598668953.59.0.945291809381.issue31749@roundup.psfhosted.org>
2020-08-29 02:42:33avisolinkissue31749 messages
2020-08-29 02:42:33avisocreate