<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: docutils: ImportError: No module named roman</title>
	<atom:link href="http://www.in-nomine.org/2009/04/07/docutils-importerror-no-module-named-roman/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.in-nomine.org/2009/04/07/docutils-importerror-no-module-named-roman/</link>
	<description>The focused mind can pierce through stone...</description>
	<lastBuildDate>Sun, 11 Dec 2011 01:53:46 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
	<item>
		<title>By: MHL</title>
		<link>http://www.in-nomine.org/2009/04/07/docutils-importerror-no-module-named-roman/comment-page-1/#comment-5042</link>
		<dc:creator>MHL</dc:creator>
		<pubDate>Thu, 21 Apr 2011 19:46:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.in-nomine.org/?p=278#comment-5042</guid>
		<description>The module &#039; roman.py &#039; in ... Python32\Lib\site-packages ...  when installed for Pyton 3x shows  (4) Syntax errors concerning the &#039;raise...&#039; command - which got new syntax in Python 3.x

  A copy of CORRECTED roman.py follows - after that it was possible to install it with Python 3.2.0.
The docutils, however, are NOT suited / adopted for Pyton 3x new SYNTAX at all - they display MANY syntax errors with &#039;raise&#039;, &#039;print&#039;, ... command !!

[code lang=&quot;python&quot;]&quot;&quot;&quot;Convert to and from Roman numerals&quot;&quot;&quot;

__author__ = &quot;Mark Pilgrim (f8dy@diveintopython.org)&quot;
__version__ = &quot;1.4&quot;
__date__ = &quot;8 August 2001&quot;
__copyright__ = &quot;&quot;&quot;Copyright (c) 2001 Mark Pilgrim

This program is part of &quot;Dive Into Python&quot;, a free Python tutorial for
experienced programmers.  Visit http://diveintopython.org/ for the
latest version.

This program is free software; you can redistribute it and/or modify
it under the terms of the Python 2.1.1 license, available at
http://www.python.org/2.1.1/license.html
&quot;&quot;&quot;

import re

#Define exceptions
class RomanError(Exception): pass
class OutOfRangeError(RomanError): pass
class NotIntegerError(RomanError): pass
class InvalidRomanNumeralError(RomanError): pass

#Define digit mapping
romanNumeralMap = ((&#039;M&#039;,  1000),
                   (&#039;CM&#039;, 900),
                   (&#039;D&#039;,  500),
                   (&#039;CD&#039;, 400),
                   (&#039;C&#039;,  100),
                   (&#039;XC&#039;, 90),
                   (&#039;L&#039;,  50),
                   (&#039;XL&#039;, 40),
                   (&#039;X&#039;,  10),
                   (&#039;IX&#039;, 9),
                   (&#039;V&#039;,  5),
                   (&#039;IV&#039;, 4),
                   (&#039;I&#039;,  1))

def toRoman(n):
    &quot;&quot;&quot;convert integer to Roman numeral&quot;&quot;&quot;
    if not (0 &lt; n = integer:
            result += numeral
            n -= integer
    return result

#Define pattern to detect valid Roman numerals
romanNumeralPattern = re.compile(&quot;&quot;&quot;
    ^                   # beginning of string
    M{0,4}              # thousands - 0 to 4 M&#039;s
    (CM&#124;CD&#124;D?C{0,3})    # hundreds - 900 (CM), 400 (CD), 0-300 (0 to 3 C&#039;s),
                        #            or 500-800 (D, followed by 0 to 3 C&#039;s)
    (XC&#124;XL&#124;L?X{0,3})    # tens - 90 (XC), 40 (XL), 0-30 (0 to 3 X&#039;s),
                        #        or 50-80 (L, followed by 0 to 3 X&#039;s)
    (IX&#124;IV&#124;V?I{0,3})    # ones - 9 (IX), 4 (IV), 0-3 (0 to 3 I&#039;s),
                        #        or 5-8 (V, followed by 0 to 3 I&#039;s)
    $                   # end of string
    &quot;&quot;&quot; ,re.VERBOSE)

def fromRoman(s):
    &quot;&quot;&quot;convert Roman numeral to integer&quot;&quot;&quot;
    if not s:
# ...        raise InvalidRomanNumeralError, &#039;Input can not be blank&#039;
        raise InvalidRomanNumeralError( &#039;Input can not be blank&#039; )
    if not romanNumeralPattern.search(s):
# ...        raise InvalidRomanNumeralError, &#039;Invalid Roman numeral: %s&#039; % s
        raise InvalidRomanNumeralError( &#039;Invalid Roman numeral: %s&#039; % s )

    result = 0
    index = 0
    for numeral, integer in romanNumeralMap:
        while s[index:index+len(numeral)] == numeral:
            result += integer
            index += len(numeral)
    return result
[/code]</description>
		<content:encoded><![CDATA[<p>The module &#8216; roman.py &#8216; in &#8230; Python32\Lib\site-packages &#8230;  when installed for Pyton 3x shows  (4) Syntax errors concerning the &#8216;raise&#8230;&#8217; command &#8211; which got new syntax in Python 3.x</p>
<p>  A copy of CORRECTED roman.py follows &#8211; after that it was possible to install it with Python 3.2.0.<br />
The docutils, however, are NOT suited / adopted for Pyton 3x new SYNTAX at all &#8211; they display MANY syntax errors with &#8216;raise&#8217;, &#8216;print&#8217;, &#8230; command !!</p>
<pre class="brush: python; title: ; notranslate">&quot;&quot;&quot;Convert to and from Roman numerals&quot;&quot;&quot;

__author__ = &quot;Mark Pilgrim (f8dy@diveintopython.org)&quot;
__version__ = &quot;1.4&quot;
__date__ = &quot;8 August 2001&quot;
__copyright__ = &quot;&quot;&quot;Copyright (c) 2001 Mark Pilgrim

This program is part of &quot;Dive Into Python&quot;, a free Python tutorial for
experienced programmers.  Visit <a href="http://diveintopython.org/" rel="nofollow">http://diveintopython.org/</a> for the
latest version.

This program is free software; you can redistribute it and/or modify
it under the terms of the Python 2.1.1 license, available at
<a href="http://www.python.org/2.1.1/license.html" rel="nofollow">http://www.python.org/2.1.1/license.html</a>
&quot;&quot;&quot;

import re

#Define exceptions
class RomanError(Exception): pass
class OutOfRangeError(RomanError): pass
class NotIntegerError(RomanError): pass
class InvalidRomanNumeralError(RomanError): pass

#Define digit mapping
romanNumeralMap = (('M',  1000),
                   ('CM', 900),
                   ('D',  500),
                   ('CD', 400),
                   ('C',  100),
                   ('XC', 90),
                   ('L',  50),
                   ('XL', 40),
                   ('X',  10),
                   ('IX', 9),
                   ('V',  5),
                   ('IV', 4),
                   ('I',  1))

def toRoman(n):
    &quot;&quot;&quot;convert integer to Roman numeral&quot;&quot;&quot;
    if not (0 &amp;lt; n = integer:
            result += numeral
            n -= integer
    return result

#Define pattern to detect valid Roman numerals
romanNumeralPattern = re.compile(&quot;&quot;&quot;
    ^                   # beginning of string
    M{0,4}              # thousands - 0 to 4 M's
    (CM|CD|D?C{0,3})    # hundreds - 900 (CM), 400 (CD), 0-300 (0 to 3 C's),
                        #            or 500-800 (D, followed by 0 to 3 C's)
    (XC|XL|L?X{0,3})    # tens - 90 (XC), 40 (XL), 0-30 (0 to 3 X's),
                        #        or 50-80 (L, followed by 0 to 3 X's)
    (IX|IV|V?I{0,3})    # ones - 9 (IX), 4 (IV), 0-3 (0 to 3 I's),
                        #        or 5-8 (V, followed by 0 to 3 I's)
    $                   # end of string
    &quot;&quot;&quot; ,re.VERBOSE)

def fromRoman(s):
    &quot;&quot;&quot;convert Roman numeral to integer&quot;&quot;&quot;
    if not s:
# ...        raise InvalidRomanNumeralError, 'Input can not be blank'
        raise InvalidRomanNumeralError( 'Input can not be blank' )
    if not romanNumeralPattern.search(s):
# ...        raise InvalidRomanNumeralError, 'Invalid Roman numeral: %s' % s
        raise InvalidRomanNumeralError( 'Invalid Roman numeral: %s' % s )

    result = 0
    index = 0
    for numeral, integer in romanNumeralMap:
        while s[index:index+len(numeral)] == numeral:
            result += integer
            index += len(numeral)
    return result
</pre>
]]></content:encoded>
	</item>
</channel>
</rss>

