brennivin.nicenum module

Functions for formatting numbers in a pretty way.

Members

brennivin.nicenum.format(num, precision)

Returns a string representation for a floating point number that is rounded to the given precision and displayed with commas and spaces.

>>> print format(123567.0, 1000)
124,000
>>> print format(5.3918e-07, 1e-10)
0.000 000 539 2

This kind of thing is wonderful for producing tables for human consumption.

brennivin.nicenum.format_memory(val)

Pretty formatting of memory.