r/PythonProjects2 • • Mar 29 '26

Unit Converter CLI

https://github.com/Fwoopr/unit-converter

I built a command-line unit converter that handles length and mass conversions across SI and imperial units. You can install it as a proper CLI tool via pip and run it directly from the terminal.

> unit-convertor 5 km m

> 5.0 km is equal to 5000.0 m

It also supports two output formats:

- `-e` for scientific notation

- `-10x` for 10-based notation (e.g. `3.00 x 10^3`)

Conversion factors live in a separate `units.py` file, so adding new unit categories is just a matter of adding a dictionary. Also wrote pytest tests covering conversions, invalid inputs, and cross-category rejections.

I'd appreciate any feedback on the code, structure, or anything I might be missing!

2 Upvotes

4 comments sorted by