Against PEP 240

Tim Peters tim.one at home.com
Fri Jun 1 02:51:51 CEST 2001


[Don O'Donnell]
> I agree with PEP 239 that Python should have a rational number type,
> but I'd like to consider the part of PEP 240, which proposes that the
> literal representation for a rational should conform to the regexp:
> r"\d+\.\d*".
>
> This representation seems to imply that all rationals must have a
> denominator which is a power of 10.  I.E., 7.35 => 735/100
> How would one write the literal for (and what would be the result
> of repr() for) the rational number 353/197 for example, using the
> literal notation  d.ddddd...?  No, this representation is too limiting
> for expressing the general case of rational numbers.  We need a more
> general format which allows both the numerator and denominator to be
> specified.
>
> Since there is talk of, and a PEP 238 advocating, changing the meaning
> of the integer divide operator "/" anyway, let's make _it_ the symbol
> for expressing rationals:
>
> >>>a = 353/197     # a is a rational number
> ...

Moshe really needs to flesh out the PEP -- that's been his intent all along.





More information about the Python-list mailing list