mod, modulo and % under 2.4 and 2.5
zuo at chopin.edu.pl
Fri Jan 1 03:04:08 CET 2010
01-01-2010 o 02:30:20 W. eWatson <wolftracks at invalid.com> 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?
There is no builtin mod() function at all, but there are (in Py 2.4, 2.5,
2.6, 3.0 and 3.1):
* builtin '%' and '%=' operators
* builtin divmod()
* in 'operator' module: mod() or __mod__() [the same] -- equivalents of
* in 'math' module: fmod() function
Additionaly, since Py 2.5 in 'operator' module there is imod() and
__imod__() [the same] -- equivalents of '%=' operator.
More information about the Python-list