ANNOUNCE: byteformat0.2a

Steven D'Aprano steve+comp.lang.python at pearwood.info
Tue May 15 04:30:53 EDT 2012


I am pleased to announce a new release of byteformat.


http://pypi.python.org/pypi/byteformat


byteformat is a Python module for intelligently formatting numbers of 
bytes using common human-readable strings:

>>> from byteformat import format
>>> format(12000)
'12 KB'
>>> format(5100000, style='ABBREV')
'5.1 Mbytes'
>>> format(48500000000000, style='LONG')
'48.5 terabytes'


byteformat understands SI decimal units, IEC binary units, and mixed 
units:

>>> format(12000, scheme='IEC')
'11.7 KiB'
>>> format(12000, scheme='MIXED')
'11.7 KB'


You can also specify which prefix to use:

>>> format(48500000000000, style='LONG', prefix='M')
'48500000 megabytes'


byteformat can be used as a command-line tool:

[steve at ando ~]$ python -m byteformat --prefix=K 1000 12300 145000 
1 KB
12.3 KB
145 KB


byteformat understands all the relevant SI and IEC unit prefixes, and is 
released under the MIT licence.



-- 
Steven



More information about the Python-list mailing list