mod, modulo and % under 2.4 and 2.5

Steven D'Aprano steve at
Fri Jan 1 02:51:15 CET 2010

On Thu, 31 Dec 2009 17:30:20 -0800, 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.

No it doesn't.

[steve at sylar ~]$ python2.5
Python 2.5 (r25:51908, Nov  6 2007, 16:54:01)
[GCC 4.1.2 20070925 (Red Hat 4.1.2-27)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> mod
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'mod' is not defined


More information about the Python-list mailing list