Skip to content

Converters

To human size

1
2
3
4
5
6
7
8
9
"""Convert the number of bytes into a human-readable format."""

from xloft import to_human_size
# from xloft.converters import to_human_size


to_human_size(200)  # => 200 bytes
to_human_size(1048576)  # => 1 MB
to_human_size(1048575)  # => 1023.999 KB

Roman

1
2
3
4
5
6
7
8
"""Convert an integer to Roman and vice versa."""

from xloft import int_to_roman, roman_to_int
# from xloft.converters import int_to_roman, roman_to_int


int_to_roman(1994)  # => MCMXCIV
roman_to_int("MCMXCIV")  # => 1994