RomanPy
RomanPy is a Python library and CLI for converting decimal numbers to Roman numerals. It provides:
- ASCII or Unicode output (with full support for Unicode numeral symbols)
- Upper- and lowercase variants
- Configurable numeral variants (subtractive, extended, apostrophus, medieval, zero, or custom mappings)
- Arithmetic operations (+, -, *, //) between Roman numerals and integers
- Equality and comparison with ints and strings
Licensed under the AGPLv3.0.
Installation
RomanPy is available on PyPI and can be installed using pip:
pip install RomanPy
Alternatively, you can pull the repository and install it straight from the source:
git clone git@scm.parcifal.dev:parcifal/RomanPy.git
cd RomanPy
pip install .
Usage (API)
Basic Conversion
from roman import roman
print(roman(207)) # CCVII
Encoding and Case Variants
n = roman(1776)
print(n.encode("ascii").upper()) # MDCCLXXVI
print(n.encode("ascii").lower()) # mdcclxxvi
print(n.encode("unicode").upper()) # ⅯⅮⅭⅭⅬⅩⅩⅥ
print(n.encode("unicode").lower()) # ⅿⅾⅽⅽⅼⅹⅹⅵ
Arithmetic with Roman Numerals
Roman numerals can be added, subtracted, multiplied, or divided with
other Roman numerals or integers:
print(roman(100) + roman(60)) # CLX
print(roman(45) - roman(7)) # XXXVIII
print(roman(533) * 2) # MLXVI
print(roman(2460) // 10) # CCXLVI
# mix with ints
print(100 + roman(60)) # CLX
print(roman(1954) == "MCMLIV") # True
Custom Variants
You can extend or override numeral variants:
from roman.roman import VARIANT_ZERO
n = roman(0).extend_variant(VARIANT_ZERO)
print(n) # N
Built-in variants include:
VARIANT_BASE(I, V, X, …)VARIANT_SUBTRACTIVE(IV, IX, XL, …)VARIANT_SUBTRACTIVE_EXTENDED(IIX, IC, …)VARIANT_ZERO(N)VARIANT_APOSTROPHUS(large numbers with I) and ((I)))VARIANT_MEDIEVAL(A, Z, O, …)
By default, VARIANT_SUBTRACTIVE is used.
Usage (CLI)
Installing RomanPy also provides a roman command-line tool:
roman 42
# = XLII
Options
usage: roman [-h] [-a | -A | -u | -U] [-b | -s | -e] [-z] [-p] [-m] [-c DECIMAL NUMERAL] [-v] [-V] value
Convert a decimal number to roman numeral.
positional arguments:
value a decimal number to convert to a roman numeral
optional arguments:
-h, --help show this help message and exit
-a, --ascii output encoding of roman numerals in lowercase ascii
-A, --ASCII output encoding of roman numerals in uppercase ascii (default)
-u, --unicode output encoding of roman numerals in lowercase unicode
-U, --UNICODE output encoding of roman numerals in uppercase unicode
-b, --no-base do not use the base variant
-s, --subtractive use the subtractive variant (includes base) (default)
-e, --subtractive-extended
use the extended subtractive variant(includes subtractive)
-z, --zero use the zero variant N
-p, --apostrophus use the apostrophus method for large numbers
-m, --medieval use the medieval variant
-c DECIMAL NUMERAL, --custom DECIMAL NUMERAL
map a decimal number to a roman numeral
-v, --verbose increase verbosity
-V, --version show program's version number and exit
Contributing
Found a bug? Have a suggestion? Open an issue or submit a merge request at the Forgejo repository. All contributions are welcome.
Metadata
Release files for RomanPy 1.3.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| romanpy-1.3.6.tar.gz | 19.3 kB | Without provenance | Details for romanpy-1.3.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| romanpy-1.3.6-py3-none-any.whl | Python 3 | none | any | Details for romanpy-1.3.6-py3-none-any.whl |
Total release size: 37.9 kB
Release files / romanpy-1.3.6.tar.gz
| Download URL | romanpy-1.3.6.tar.gz |
|---|---|
| Size | 19.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
617f6f63e2666b4806f136c25b2723d30c9777f0d94109b6c73957e639daeba3
|
|
BLAKE2b-256 checksum How to use checksums |
6e053292186098eafe04a655a8f35f41884d1b29082793c1a2083f223a535e67
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.5
|
Release files / romanpy-1.3.6-py3-none-any.whl
| Download URL | romanpy-1.3.6-py3-none-any.whl |
|---|---|
| Size | 18.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
300fa9cebed662bad46b5f151b56afeb077116fd74595a3d48e8a172f5b0d748
|
|
BLAKE2b-256 checksum How to use checksums |
ba7fe18b7429e34112de65ffd463711d3a17b269d0cfd53f397f852d1e482576
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.5
|
Security for RomanPy 1.3.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.