punits 0.2

Last updated:

0 purchases

punits 0.2 Image
punits 0.2 Images
Add to Cart

Description:

punits 0.2

punits



A simple utility to convert values between different units.
Installation
You need Python>=3.6 to use punits.
It can be installed from PyPI with pip using
pip install punits

Command line usage
python3 -m punits <choice> <source-unit> <target-unit> <value-list>

where choice is the kind of units. Allowed values for are:

mass
length
volume
data
temperature.

For example, you can use
python3 -m punits mass lb kg 23 46.2 12.46

to get
10.43 20.96 5.65

Use python3 -m punits --help for more information.
Usage as module
The punits() function can be used.
Its signature is:
def punits(measure: str,
src_unit: str,
target_unit: str,
values: List[float],
params: Optional[dict] = None) -> List[float]

where the params argument can be used to pass additional parameters that may be needed (like dpi value when conversion is from or to pixesl).
For example,
>>> punits.punits('temperature', 'K', 'C', [235, 123.2])
[-38.14999999999998, -149.95]

or
>>> punits.punits('length', 'px', 'mm', [235, 123.2], {'dpi': 200})
[29.844999999999995, 15.646400000000002]

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.