[New-bugs-announce] [issue31749] Request: Human readable byte amounts in the standard library

Rich report at bugs.python.org
Tue Oct 10 13:10:53 EDT 2017


New submission from Rich <miserlou+python2 at gmail.com>:

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

----------
messages: 304061
nosy: miserlou2
priority: normal
severity: normal
status: open
title: Request: Human readable byte amounts in the standard library
type: enhancement
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31749>
_______________________________________


More information about the New-bugs-announce mailing list