Skip to main content

A practical Roman numerals implementation

Project description

New in version 0.0.2:

  • Fix bug that did not allow numbers greater than MCMXCIX

pip install rome==0.0.2

rome is the first industrial-strength Roman numerals implementation for Python. It features Roman-to-Arabic and Arabic-to-Roman numerals convertion, as well as normalization of denormalized Roman numerals using unified object-oriented interface. It is developed using test-driven development, and features an extensive test-suite.

>>> from rome import Roman

>>> Roman('IX')
Roman('IX')

>>> str(Roman('IX'))
'IX'

>>> int(Roman('IX'))  # to Arabic numerals
9

>>> Roman('IX') == 9
True

>>> Roman('IX') + Roman('XI') == Roman('XX')
True

>>> Roman('XXI') - 13 == 8
True

>>> Roman(4)  # from Arabic numerals
Roman('IV')

>>> Roman(1903)
Roman('MCMIII')

>>> Roman('IIII')  # bring to normalized form
Roman('IV')

>>> Roman('MDCCCCLXXXXVIIII')
Roman('MCMXCIX')

>>> int(Roman('MCMXCIX'))
1999

>>> int(Roman('M cM xC iX'))  # spaces and mixed case are
...                           # allowed for readability
1999

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

rome-0.0.2.tar.gz (3.1 kB view details)

Uploaded Source

File details

Details for the file rome-0.0.2.tar.gz.

File metadata

  • Download URL: rome-0.0.2.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for rome-0.0.2.tar.gz
Algorithm Hash digest
SHA256 4432d7c3138a4392c5300a2eeef2efb7b963605ddcf4c4b7e0f09db2abd360e6
MD5 fa48ad80b0e3c81a3bf1bd703cf62b7b
BLAKE2b-256 c777eb09174371766a8844104c868cdd147e333c2287b3a079e7a2bc8cb7c6f8

See more details on using hashes here.

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