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]
Metadata
Release files for punits 0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| punits-0.2.tar.gz | 8.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| punits-0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.3 kB
Release files / punits-0.2.tar.gz
| Download URL | punits-0.2.tar.gz |
|---|---|
| Size | 8.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c7483ef7a900b003e16c1f06e84f3150f97c97cdfef8de4aee83b7723457c66e
|
|
BLAKE2b-256 checksum How to use checksums |
b32696c1242659b9338af7e13cba47b7418b8237d7f46b49e489d581f0a80dbc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.9
|
Release files / punits-0.2-py3-none-any.whl
| Download URL | punits-0.2-py3-none-any.whl |
|---|---|
| Size | 11.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d9d348b2201e40837d7b885a129e2899b1b43afba4cf64355229a4889094a575
|
|
BLAKE2b-256 checksum How to use checksums |
17f6ab99c7fcb0180f017f36642a6b900a2958d03faec375334607e9e7f77afb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.9
|