Message304061
This problem is an _extremely_ common one, a problem that almost any Python project of a reasonable size will encounter.
Given a number of bytes, say 123901842, format this as '123.9MB'.
The reason I strongly think that this should be included in the standard library is that if you look for how to do this through a Google search, there are an incredible amount of different solutions on StackOverflow, blog posts, forum posts, and various different libraries which provide this functionality - with varying levels of functionality and safety. You can also find different implementations of solutions to this problem inside of pretty much every major Python project (Django, etc.). In fact, I don't think I can think of any other function that gets copy-pasted into a project's 'util.py' file more commonly.
I think this should functionality should be provided in the standard math package, with arguments which allow to specific SI/NIST formatting and the number of significant digits to display. Implementing this would strongly cut down on the amount of cargo-cult Python programming in the world.
I'm willing to implement this if there's a consensus that it should be included.
Thanks!,
Rich Jones |
|
Date |
User |
Action |
Args |
2017-10-10 17:10:53 | miserlou2 | set | recipients:
+ miserlou2 |
2017-10-10 17:10:53 | miserlou2 | set | messageid: <1507655453.9.0.213398074469.issue31749@psf.upfronthosting.co.za> |
2017-10-10 17:10:53 | miserlou2 | link | issue31749 messages |
2017-10-10 17:10:53 | miserlou2 | create | |
|