~ubuntu-branches/ubuntu/lucid/python2.6/lucid

« back to all changes in this revision

Viewing changes to Doc/tools/roman.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2010-03-11 13:30:19 UTC
  • mto: (10.1.13 sid)
  • mto: This revision was merged to the branch mainline in revision 44.
  • Revision ID: james.westby@ubuntu.com-20100311133019-sblbooa3uqrkoe70
Tags: upstream-2.6.5~rc2
ImportĀ upstreamĀ versionĀ 2.6.5~rc2

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
def toRoman(n):
41
41
    """convert integer to Roman numeral"""
42
42
    if not (0 < n < 5000):
43
 
        raise OutOfRangeError, "number out of range (must be 1..4999)"
44
 
    if int(n) <> n:
45
 
        raise NotIntegerError, "decimals can not be converted"
 
43
        raise OutOfRangeError("number out of range (must be 1..4999)")
 
44
    if int(n) != n:
 
45
        raise NotIntegerError("decimals can not be converted")
46
46
 
47
47
    result = ""
48
48
    for numeral, integer in romanNumeralMap:
67
67
def fromRoman(s):
68
68
    """convert Roman numeral to integer"""
69
69
    if not s:
70
 
        raise InvalidRomanNumeralError, 'Input can not be blank'
 
70
        raise InvalidRomanNumeralError('Input can not be blank')
71
71
    if not romanNumeralPattern.search(s):
72
 
        raise InvalidRomanNumeralError, 'Invalid Roman numeral: %s' % s
 
72
        raise InvalidRomanNumeralError('Invalid Roman numeral: %s' % s)
73
73
 
74
74
    result = 0
75
75
    index = 0