Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Integer subset class using Roman numeral input and output

Project Description

A "Roman" object is stored in the computer as a binary integer,
but it is displayed in Roman numerals.
(In technical terms, it is a subset of the built-in class int,
with a _str_() method which returns a Roman numeral string.)
[see PEP 313 for the inspiration]

This module has .toRoman() and .fromRoman() methods compatible with Mark Pilgrim's module, but has a larger range, a more forgiving parser, and allows construction of first class Roman objects.

Roman objects act very much like the built-in Decimal objects in Python,
they can be added, subtracted, multiplied, or divided and the result will be
another object of the same class.

So a programmer can say:

>>>import romanclass as roman

>>>two = roman.Roman(2)

>>>five = roman.Roman('V')

>>>print (two+five)

and the computer will print:


This module uses unicode characters to support numbers in the range 0<=n<600000,
and has an optional .toUnicodeRoman() method which will output true unicode
character points for I V X L C D M (rather than their look-alike ASCII values)
and will output the points for I thru XII as single unicode code points.

The .toRoman() method [and the str() function] will output ASCII compatible
strings for values <= 3999.

The string "Nulla" [Latin for "nothing"] will be output for a zero value.

Out of range values will raise romanclass.OutOfRangeError

Badly formatted Roman numeral input strings will raise romanclass.InvalidRomanNumeralError in .fromRoman() or when initializing a Roman object., A simple four-function Roman calculator is included as a test/demo.

Release History

This version
History Node


Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(105.2 kB) Copy SHA256 Hash SHA256
Source None Aug 12, 2010

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Google Google Cloud Servers DreamHost DreamHost Log Hosting