PEP0238 lament

James Logajan JamesL at Lugoj.Com
Sun Jul 22 16:29:45 EDT 2001


Tim Peters wrote:
> By show of hands, about 3/4ths of the
> participants agreed that 3/4 should not return 0, but rather *something* x
> such that x*4 had a better chance of being confused with 3 than with 0.
> There was no consensus on exactly what 3/4 should return -- rational or HW
> float or decimal float were the most popular alternatives.

This has probably already been brought up, but perhaps the problem lies not
with the "/" operator, but one step earlier in distinguishing the meaning
of:

x = 3
and
x = 3.

That is subtle difference that can cause quite different results later on.

Or, one may try to teach that when ALL arguments of an operator are in one
"set", such as the set of integers, then one must expect a result that is an
element from THAT set, not another set, such as the set of real numbers or
from the set of complex numbers. Set theory seems to be taught fairly early
on in math, I think.

It has been my observation that people can often quickly grasp and make use
of the common underlying general principles behind things after having seen
only a few examples, provided there is a CONSISTENT underlying principle. A
handful of general rules may be easier to teach than a collection of special
cases. So can and should Python adopt an underlying principle along the
lines where one can grasp the following pattern:

integer = integer operator integer
real = integer operator real
real = real operator integer
real = real operator real
complex = integer operator complex
...

I prefer a handful of general rules, and operators that obey them.



More information about the Python-list mailing list