update from Mike Meyer
This commit is contained in:
parent
9d9fae78f3
commit
e410f1eb53
22
pep-0313.txt
22
pep-0313.txt
|
@ -13,10 +13,11 @@ Post-History:
|
||||||
|
|
||||||
Abstract
|
Abstract
|
||||||
|
|
||||||
This PEP proposes adding Roman numerals as a literal type. It
|
This PEP (also known as PEP CCCXIII) proposes adding Roman
|
||||||
also proposes the new built-in function "roman", which converts an
|
numerals as a literal type. It also proposes the new built-in
|
||||||
object to an integer, then converts the integer to a string that
|
function "roman", which converts an object to an integer, then
|
||||||
is the Roman numeral literal equivalent to the integer.
|
converts the integer to a string that is the Roman numeral literal
|
||||||
|
equivalent to the integer.
|
||||||
|
|
||||||
|
|
||||||
Rationale
|
Rationale
|
||||||
|
@ -38,12 +39,13 @@ Syntax for Roman literals
|
||||||
case, and represent an integer with the following rules:
|
case, and represent an integer with the following rules:
|
||||||
|
|
||||||
1. Except as noted below, they must appear in the order M, D, C,
|
1. Except as noted below, they must appear in the order M, D, C,
|
||||||
L, X, V then I. Each occurence of each character adds 1000, 500,
|
L, X, V then I. Each occurrence of each character adds 1000, 500,
|
||||||
100, 50, 10, 5 and 1 to the value of the literal, respectively.
|
100, 50, 10, 5 and 1 to the value of the literal, respectively.
|
||||||
|
|
||||||
2. Only one D, V or L may appear in any given literal.
|
2. Only one D, V or L may appear in any given literal.
|
||||||
|
|
||||||
3. At most three Is, Xs and Cs may appear in any given literal.
|
3. At most three each of Is, Xs and Cs may appear consecutively
|
||||||
|
in any given literal.
|
||||||
|
|
||||||
4. A single I may appear immediately to the left of the single V,
|
4. A single I may appear immediately to the left of the single V,
|
||||||
followed by no Is, and adds 4 to the value of the literal.
|
followed by no Is, and adds 4 to the value of the literal.
|
||||||
|
@ -62,21 +64,21 @@ Syntax for Roman literals
|
||||||
because explicit is better than implicit.
|
because explicit is better than implicit.
|
||||||
|
|
||||||
|
|
||||||
Builtin "roman" Function
|
Built-In "roman" Function
|
||||||
|
|
||||||
The new builtin function "roman" will aide the translation from
|
The new built-in function "roman" will aide the translation from
|
||||||
integers to Roman numeral literals. It will accept a single
|
integers to Roman numeral literals. It will accept a single
|
||||||
object as an argument, and return a string containing the literal
|
object as an argument, and return a string containing the literal
|
||||||
of the same value. If the argument is not an integer or a
|
of the same value. If the argument is not an integer or a
|
||||||
rational (see PEP 239 [1]) it will passed through the existing
|
rational (see PEP 239 [1]) it will passed through the existing
|
||||||
builtin "int" to obtain the value. This may cause a loss of
|
built-in "int" to obtain the value. This may cause a loss of
|
||||||
information if the object was a float. If the object is a
|
information if the object was a float. If the object is a
|
||||||
rational, then the result will be formatted as a rational literal
|
rational, then the result will be formatted as a rational literal
|
||||||
(see PEP 240 [2]) with the integers in the string being Roman
|
(see PEP 240 [2]) with the integers in the string being Roman
|
||||||
numeral literals.
|
numeral literals.
|
||||||
|
|
||||||
|
|
||||||
Compatability Issues
|
Compatibility Issues
|
||||||
|
|
||||||
No new keywords are introduced by this proposal. Programs that
|
No new keywords are introduced by this proposal. Programs that
|
||||||
use variable names that are all upper case and contain only the
|
use variable names that are all upper case and contain only the
|
||||||
|
|
Loading…
Reference in New Issue