datasize
datasize copied to clipboard
Python integer subclass to handle arithmetic and formatting of integers with data size units
```Python '{0:a}'.format(DataSize('14796MB')) >>> '13.779849GiB' '{0:B}'.format(DataSize('14796MB')) >>> '14796000000EB' ``` should look more like ```Python '{0:B}'.format(DataSize('14796MB')) >>> '14796000000B' ```
``` >>> DataSize(4836071272) >>> Traceback (most recent call last): File "", line 1, in File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/datasize/__datasize__.py", line 97, in __new__ raw = spec[:] TypeError: 'int' object is not subscriptable ```
http://matplotlib.org/api/ticker_api.html#matplotlib.ticker.FuncFormatter
This ``` >>> '{}'.format(DataSize(1)) >>> '1B ' ``` should work more like ``` >>> '{}'.format(DataSize(1)) >>> '1B' ```
DataSize can produce strings like "1.47MiB" by format strings like '{:.2MiB}' but there is no way to specify that it should print the slightly prettier "1.47 MiB" with a space...