Convert integers to roman numerals and vice versa
roman_numbers is a simple Python library that lets you convert from python int to roman numerals (represented as a python string) or convert from roman numerals to python int.
To install this script you need setuptools From the command line run
[sudo] python[3] setup.py install
If you want to run test locally you can simply
python[3] test_roman_numbers.py
or, if you have installed pytest, you can run
pytest
Once installed you can simply import this module
in the usual way. For a complete function
documentation refer to pydoc
.
No system to write large roman numeral is currently supported.
Convetion functions are available in two different forms:
-
safe: those versions(function name end with _safe) perform checks on the input, ensuring that input type is correct and input variables are in the right form.
-
fast: those versions don't perform any check on the input, assuming the values are both of the correct type and in the correct form.
-
int_to_roman
(integer to roman numeral convertion) consider as correct input any python integer lerger then zero -
roman_to_int
(roman numeral to integer convertion) consider as correct input ant python string that contains a correct roman numeral and nothing more. To test if a string is correct or notis_valid_roman
function is available
See example.py