[Python-3000] bug in modulus?

Greg Ewing greg.ewing at canterbury.ac.nz
Thu May 4 03:06:34 CEST 2006


Michael Chermside wrote:

> Providing both operations is a no-brainer. But only one gets to be
> spelled "x % y".

Personally I wouldn't mind if *neither* operation on
floats were spelled x % y. The number of times I can
remember doing a mod on floats is vanishingly small,
and I'd never be able to remember exactly how the one
chosen for % worked anyway. So giving them both explicit
names would be the most helpful thing for me.

> Beginners will care that floats and integers
> behave "the same"

To my mind, % is inherently an integer operation, and
doing the "same" thing for floats doesn't even make
sense. Raising an exception would be a good way of
giving newbies a gentle hint that they need to be more
explicit.

--
Greg


More information about the Python-3000 mailing list