How about adding rational fraction to Python?
Paul Rubin
http
Wed Feb 27 21:08:29 EST 2008
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.
> 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.
More information about the Python-list
mailing list