Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

convunits-0.0.1.tar.gz (20.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

convunits-0.0.1-py3-none-any.whl (39.1 kB view details)

Uploaded Python 3

File details

Details for the file convunits-0.0.1.tar.gz.

File metadata

  • Download URL: convunits-0.0.1.tar.gz
  • Upload date:
  • Size: 20.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.11

File hashes

Hashes for convunits-0.0.1.tar.gz
Algorithm Hash digest
SHA256 eb5b764e34e4b522dbc5ea83e6a900a7abb16f8d4c43b8cf0f4643a307b95594
MD5 5f2cc70e2cccabed04a6c50e3b631ec9
BLAKE2b-256 860e83969e62e8c96bd0722cab74235548f848a0ef19c5a060be3b64d034c55c

See more details on using hashes here.

File details

Details for the file convunits-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: convunits-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 39.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.11

File hashes

Hashes for convunits-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c1a3d2d08c977b0517ece8437fc54dd440cd26899feccc4db58396cba5f67a4b
MD5 f7cc6db9cffeabdea998e6f755f47502
BLAKE2b-256 0184d21461e64ac6ca497505b00c29d3df676120c3141c6256779665f5d17b1e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page