modunits module¶
Convert computer-friendly numbers to human-readable numbers with units at various levels of detail.
- class modunits.Item(amount: float, type_: modunits.Type, after: bool, units: str, fractional_part_length: int)[source]¶
Bases:
object
Hold one of the modular pieces of our number.
- class modunits.Type(threshold: Optional[int], unabbreviated: str, abbreviated: str)[source]¶
Bases:
object
Hold data about whether we should output units abbreviated or unabbreviated, and what to divide by (?).
- modunits.modunits(unitsvector: Union[str, List[modunits.Type]], number: int, detail: str = 'highest-and-fraction', units: str = 'abbreviated', comma: bool = True, reverse: bool = False, after: bool = True, fractional_part_length: int = - 1)[source]¶
Convert a number with computer-friendly units into something more human-readable.
Main entry point for the module.