News and announcements

Roman number module gets setup.py tool

Written for Roman class for python by Vernon Cole on 2010-08-11

Installation of the Roman Number python class module is now eased by having a distutils based setup.py file included. The module name has been changed to "romanclass" in order to avoid conflict with a previously published "roman.py".
  Since setup.py will automatically convert the module to Python 3 syntax if needed, the former test "__main__" code has been converted to a .test() method -- so in Python 3 you can do "pythonclass.test()" to get the test printout.
The module has been tested using CPython 2.6, 2.7, Python 3.1, 3.2a1, and IronPython 2.6 and 2.7a1.
[Note: distutils is broken on IronPython -- you will have to copy the module to site-packages yourself, for now.]

python Roman number (PEP 313) class

Written for Roman class for python by Vernon Cole on 2009-12-24

The proposal to add Roman numeral literals to Python was presented on (nudge, nudge) April 1st, 2003 by Mike Meyers.
The PEP was rejected by BDFL due to (he said) differences of opinion as to proper syntax of Roman strings.
This submission is (really and truly) an implementation of PEP 313 as a module, in the spirit of the decimal module. The module is a demonstration of defining an object which is a subset of 'int'. It will accept integers, Arabic number string literals, or Roman string literals as the argument to its constructor. Due to the simplicity of its Roman-to-binary parser, it will accept almost any string which is understandable as a Roman number. For example str(roman.Roman('viiii')) will return 'IX'. To obtain lower case output, use .tolower(). I was disturbed by the limitations of existing Roman number algorithms which were limited to a range of 1 <= n < 4000. (A typical Roman legion consisted of 5300 to 6000 soldiers, so they must have been able to write large numbers.) A little research revealed the unicode code points for the larger digits. In the spirit of "explicit is better than implicit" I also added a representation for Zero -- the Latin word "Nulla" meaning "nothing." I think that it is better to print "nothing" than nothing, if you see what I mean. This module will operate in the range 0 <= n < 600000. A Python 3 version is included.

12 of 2 results