A modest PEP0238 suggestion

Stephen Horne steve at lurking.demon.co.uk
Wed Jul 25 04:04:21 EDT 2001


On Wed, 25 Jul 2001 05:12:17 GMT, Guido van Rossum <guido at python.org>
wrote:

>paul at svensson.org (Paul Svensson) writes:
>
>(Thanks for your nice table, BTW.)
>
>> The only choices that make sense to me here are, either we break stuff,
>> or we do nothing.  Either way, we'll most likely have to revisit the
>> issue if/when syntax for rationals is to be added to the language.
>
>Actually, adding rationals can be done almost entirely without
>breaking code...  That is, *if* we adopt PEP-238 now.  Changing 1/2
>from returning a float to returning a rational won't have to break
>code, since the mathematical value of the result is the same.
>Changing it from returning 0 to returning a rational isn't any easier
>than changing it from returning 0 to returning a float -- exactly the
>same places will have to be changed.
>
>If you're for rationals, you're for PEP-238.

Nope.

I don't mind rationals, but they are a continuous measure. If integer
calculations are going to be allowed to return rationals then we need
separate integer types for integer-within-real and discrete-integer.

I'd want to see...

>>> print 10 / 4
2
>>> print 10.0 / 4
2.5
>>> print 10R / 4
5/2




More information about the Python-list mailing list