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
|
||||
|
||||
This PEP proposes adding Roman numerals as a literal type. It
|
||||
also proposes the new built-in function "roman", which converts an
|
||||
object to an integer, then converts the integer to a string that
|
||||
is the Roman numeral literal equivalent to the integer.
|
||||
This PEP (also known as PEP CCCXIII) proposes adding Roman
|
||||
numerals as a literal type. It also proposes the new built-in
|
||||
function "roman", which converts an object to an integer, then
|
||||
converts the integer to a string that is the Roman numeral literal
|
||||
equivalent to the integer.
|
||||
|
||||
|
||||
Rationale
|
||||
|
@ -38,12 +39,13 @@ Syntax for Roman literals
|
|||
case, and represent an integer with the following rules:
|
||||
|
||||
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.
|
||||
|
||||
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,
|
||||
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.
|
||||
|
||||
|
||||
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
|
||||
object as an argument, and return a string containing the literal
|
||||
of the same value. If the argument is not an integer or a
|
||||
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
|
||||
rational, then the result will be formatted as a rational literal
|
||||
(see PEP 240 [2]) with the integers in the string being Roman
|
||||
numeral literals.
|
||||
|
||||
|
||||
Compatability Issues
|
||||
Compatibility Issues
|
||||
|
||||
No new keywords are introduced by this proposal. Programs that
|
||||
use variable names that are all upper case and contain only the
|
||||
|
|
Loading…
Reference in New Issue