mod, modulo and % under 2.4 and 2.5
python at mrabarnett.plus.com
Fri Jan 1 03:15:33 CET 2010
W. eWatson wrote:
> About a year ago, I wrote a program that used mod() for modulo under
> 2.5. Apparently, % is also acceptable, but the program works quite
> well. I turned the program over to someone who is using 2.4, and
> apparently 2.4 knows nothing about mod(). Out of curiosity, what
> library is mod(a,b)(two args) in? It doesn't seem to be in numpy. It
> seems to be built-in. If so, why isn't it both 2.4 and 2.5?
mod() not is a built-in.
It is, however, in the 'operator' module, and also as __mod__() in that
same module. Both are equivalent to '%'.
It has been there since at least Python v2.0.
As for why something might not be in an earlier version, well, that
would be because it hadn't been added yet! :-)
More information about the Python-list