469,915 Members | 2,635 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,915 developers. It's quick & easy.

Re: formatting number of bytes to human readable format

On 13 Aug 2008, rkmr wrote:
is there any library / function that prints number of bytes in human
readable format?
for example

a=XX(1048576)
print a

should output
1 MB
http://mail.python.org/pipermail/pyt...er/018519.html
is a good start - just need to change the table to something like::

_abbrevs = [
(2 ** 30L - 1, 'G'),
(2 ** 20L - 1, 'M'),
(2 ** 10L - 1, 'K'),
(1, '')
]

(and add a 'B').

--
-rob

Aug 13 '08 #1
0 1281

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Gerrit Holl | last post: by
20 posts views Thread by Pierre Fortin | last post: by
9 posts views Thread by Alex Willmer | last post: by
13 posts views Thread by Kosio | last post: by
9 posts views Thread by Simon Osborn | last post: by
7 posts views Thread by L. Scott M. | last post: by
8 posts views Thread by victor.herasme | last post: by
3 posts views Thread by lilly07 | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.