How about adding rational fraction to Python?
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Wed Feb 27 21:47:45 EST 2008
On Wed, 27 Feb 2008 18:08:29 -0800, Paul Rubin wrote:
> Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> writes:
>> When it comes to mixed arithmetic, it's just too darn inconvenient to
>> forbid automatic conversions. Otherwise you end up either forbidding
>> things like 1 + 1.0 on the basis that it isn't clear whether the
>> programmer wants an int result or a float result,
>
> You can parse 1 as either an integer or a floating 1, so 1 + 1.0 can be
> correctly typed as a float. However (for example), len(x) is always an
> int so len(x) + 1.0 would be forbidden.
Okay, that's just insane, making distinctions between literals and
variables like that.
1 + 1.0 # okay
x = 1
x + 1.0 # is this okay or not? who knows?
len('s') + 1.0 # forbidden
I am so glad you're not the designer of Python.
>> or else even more complex rules ("if the left operator is an int, and
>> the result of the addition has a zero floating-point part, then the
>> result is an int,
>
> That is ugly and unnecessary.
Which was my point.
--
Steven
More information about the Python-list
mailing list