Created
April 15, 2010 22:42
-
-
Save deleted/367763 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sizeof_human(numbytes): | |
''' Human-readable size strings ''' | |
assert numbytes >= 0 | |
for x in ['bytes','KB','MB','GB','TB','PB']: | |
if numbytes < 1024.0: | |
return "%3.2f%s" % (numbytes, x) | |
numbytes /= 1024.0 | |
else: | |
return "Exabytes!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment