PEP 313 - Roman numeral literals

Ben Hutchings do-not-spam-ben.hutchings at businesswebsoftware.com
Thu Apr 3 12:29:58 EST 2003


In article <b6fvj9$518n3$1 at ID-169208.news.dfncis.de>,
Greg Ewing (using news.cis.dfn.de) wrote:
> sismex01 at hebmex.com wrote:
>> No, the correct writing of 39 in roman numerals is "XXXIX",
>> the proposed rule for only 3 of X, I or C in a single number
>> is premature, or incomplete.
>> 
>> It should read "3 consecutive X, I or C digits".
> 
> You shouldn't need to explicitly state any such rule
> if the rest of the rules are formulated properly.
> 
> The best way would be to specify a grammar in some
> form, e.g. a regular expression.

Right, like this:

   M{0,3}(D?C{0,3}|C[DM])(L?X{0,3}|X[LC])(V?I{0,3}|I[VX])

But since the use of subtraction was apparently a late addition
to the system, we should allow the purists to do without it:

   M{0,3}((D?C{0,3}|C[DM])(L?X{0,3}|X[LC])(V?I{0,3}|I[VX])|D?C{0,4}L?X{0,4}V?I{0,4})

The problem of confusion with existing identifiers can be dealt
with once Python supports Unicode source files, when we can use
this simple expression:

   \u216F{0,3}((\u216E?\u216D{0,3}|\u216D[\u216E\u216F])(\u216C?\u2169{0,3}|\u2169[\u216C\u216D])(\u2164?\u2160{0,3}|\u2160[\u2164\u2169])|\u216E?\u216D{0,4}\u216C?\u2169{0,4}\u2164?(\u2160{0,4})

Of course we would also need to deal with overbars for 5000,
10000, and so on.




More information about the Python-list mailing list