proposed language change to int/int==float (was: PEP0238 lament)
rwallace at esatclear.ie
Fri Jul 27 05:06:51 CEST 2001
On 26 Jul 2001 15:50:15 +1200, Paul Foley <see at below> wrote:
>But rationals _are_ already in the language. Integers are rationals.
>"/" should definitely return an integer when the result can be
>represented in an integer. E.g., 4/2 should return 2, not 2.0.
The way it works right now is that the _type_ of the result depends on
the _type_ of the operands. You could argue about whether the specific
case of the current / operator is a bit too error prone, but generally
speaking this is reasonable behavior.
You want the _type_ of the result to depend on the _value_ of the
operands. My reaction to that is ***NO!!!*** It would make the
division operator for integer operands so error prone as to be
unusable. If that's the intent, much better to have it be an error to
use integer operands, that way you wouldn't get silently and
inconsistently wrong answers.
"How many roads must a man walk down?"
mailto:rwallace at esatclear.ie
More information about the Python-list