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 miserlou2
Recipients miserlou2
Date 2017-10-10.17:10:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1507655453.9.0.213398074469.issue31749@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2017-10-10 17:10:53miserlou2setrecipients: + miserlou2
2017-10-10 17:10:53miserlou2setmessageid: <1507655453.9.0.213398074469.issue31749@psf.upfronthosting.co.za>
2017-10-10 17:10:53miserlou2linkissue31749 messages
2017-10-10 17:10:53miserlou2create