romanclass 1.0.1

Creator: railscoderz

Last updated:

0 purchases

romanclass 1.0.1 Image
romanclass 1.0.1 Images

Languages

Categories

Add to Cart

Description:

romanclass 1.0.1

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 roman.py 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:

VII

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.

CaesarCalc.py, A simple four-function Roman calculator is included as a test/demo.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.