Docutils -- Python Documentation Utilities
Project description
A library for manipulating well-formed Roman numerals.
Integers between 1 and 3,999 (inclusive) are supported. Numbers beyond this range will return an OutOfRangeError.
The classical system of roman numerals requires that the same character may not appear more than thrice consecutively, meaning that ‘MMMCMXCIX’ (3,999) is the largest well-formed Roman numeral. The smallest is ‘I’ (1), as there is no symbol for zero in Roman numerals.
Both upper- and lower-case formatting of roman numerals are supported, and likewise for parsing strings, although the entire string must be of the same case. Numerals that do not adhere to the classical form are rejected with an InvalidRomanNumeralError.
Example usage
Creating a roman numeral
from roman_numerals import RomanNumeral
num = RomanNumeral(16)
assert str(num) == 'XVI'
num = RomanNumeral.from_string("XVI")
assert int(num) == 16
Convert a roman numeral to a string
from roman_numerals import RomanNumeral
num = RomanNumeral(16)
assert str(num) == 'XVI'
assert num.to_uppercase() == 'XVI'
assert num.to_lowercase() == 'xvi'
assert repr(num) == 'RomanNumeral(16)'
Extract the decimal value of a roman numeral
from roman_numerals import RomanNumeral
num = RomanNumeral(42)
assert int(num) == 42
Invalid input
from roman_numerals import RomanNumeral, InvalidRomanNumeralError
num = RomanNumeral.from_string("Spam!") # raises InvalidRomanNumeralError
num = RomanNumeral.from_string("CLL") # raises InvalidRomanNumeralError
num = RomanNumeral(0) # raises OutOfRangeError
num = RomanNumeral(4_000) # raises OutOfRangeError
Licence
This project is placed in the public domain or under the terms of the ‘Zero Clause BSD licence’, whichever is more permissive.
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
File details
Details for the file roman_numerals_py-1.0.0.tar.gz
.
File metadata
- Download URL: roman_numerals_py-1.0.0.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 496f5748817b9560de3e33e127f7c511d16b227a44827ffc2967d77b94a10a4d |
|
MD5 | 17785964afdf4be153c8b136c6eeac36 |
|
BLAKE2b-256 | effd3435d8d394a93bba0bf1fe10b93af56c68bf3c829f7385bce674aca5d0fc |
Provenance
The following attestation bundles were made for roman_numerals_py-1.0.0.tar.gz
:
Publisher:
create-release.yml
on AA-Turner/roman-numerals
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
roman_numerals_py-1.0.0.tar.gz
- Subject digest:
496f5748817b9560de3e33e127f7c511d16b227a44827ffc2967d77b94a10a4d
- Sigstore transparency entry: 147862317
- Sigstore integration time:
- Predicate type:
File details
Details for the file roman_numerals_py-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: roman_numerals_py-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6bcc47955d5fb3c3ee0f79cfee80756f8c76edd553c840b0d37203668161e7bd |
|
MD5 | 01b67b34d5397abd0c26f4e7a72ca412 |
|
BLAKE2b-256 | 7925aea62cd3272f4b7e1d1c980b5a63c3eb2972db5f9682a9149e3568a52f16 |
Provenance
The following attestation bundles were made for roman_numerals_py-1.0.0-py3-none-any.whl
:
Publisher:
create-release.yml
on AA-Turner/roman-numerals
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
roman_numerals_py-1.0.0-py3-none-any.whl
- Subject digest:
6bcc47955d5fb3c3ee0f79cfee80756f8c76edd553c840b0d37203668161e7bd
- Sigstore transparency entry: 147862316
- Sigstore integration time:
- Predicate type: