Skip to main content

No project description provided

Project description

roman-nums

Python library to work with roman numbers.

Installation

Use the package manager pip to install roman-nums.

pip install roman-nums

Base usage

>>> from roman_nums import to_roman, from_roman
...
>>> to_roman(154)
CLIV
>>> from_roman('MCCCXLVI')
1346

Work with validation

>>> from roman_nums.utils import rn_validator
...
>>> rn_validator('XLIV')
True
>>> rn_validator('XLIVV')
False

Work with texts

Find roman and arabic numbers in text. Convert them.

>>> from roman_nums.utils import RText
...
text = """
In 1066, Norman troops <...>.
In the XII century, England conquered Wales, and at the beginning of the XVIII century <...>.
"""

>>> worker = RText(text)
>>> worker.from_roman()
In 1066, Norman troops <...>.
In the 12 century, England conquered Wales, and at the beginning of the 18 century <...>.

>>> worker.to_roman()
In MLXVI, Norman troops <...>.
In the XII century, England conquered Wales, and at the beginning of the XVIII century <...>.

>>> worker.rnb()    # Will find all roman numbers
['XII', 'XVIII']

>>> worker.nb()     # Will find all arabic numbers
[1066]

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

roman_nums-0.0.1.tar.gz (4.4 kB view hashes)

Uploaded Source

Supported by

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