Unit-Converter Python library (py version of convunits)
Project description
# Python Unit-Converter library (py version of convunits)
This library serves as the Python equivalent of the original convunits library written in TypeScript.
## Installation
Use the Python package manager (i.e. pip) to install convunits.
`bash pip install convunits `
## Usage
In general, you can convert from one unit of the same quantity to another.
`python >>> from convunits import Convert >>> Convert(10, 'km').to('miles') 6.2137121212121205 `
Also works with arrays (lists, and such to some extent):
`python >>> from convunits import Convert >>> Convert([1, 2, 3], 'm').to('ft') array([3.28084, 6.56168, 9.84252]) `
## Contributing
### Adding new units
To add new units to convunits, add or update one of the JSON definitions in the definitions. Once the definitions is updated, regenerate all the Python unit definitions by running the json_to_py.py script in tools directory:
`bash python tools/json_to_py.py `
And check that the new units have been included in py/convunits/unit_definitions/* files and also in py/convunits/definitions file (if it’s a new quantity).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for convunits-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c1a3d2d08c977b0517ece8437fc54dd440cd26899feccc4db58396cba5f67a4b |
|
MD5 | f7cc6db9cffeabdea998e6f755f47502 |
|
BLAKE2b-256 | 0184d21461e64ac6ca497505b00c29d3df676120c3141c6256779665f5d17b1e |