mod, modulo and % under 2.4 and 2.5

W. eWatson wolftracks at invalid.com
Thu Dec 31 21:06:25 EST 2009


Steven D'Aprano wrote:
> 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
> 
> 
So where is it? Here are the choices.
import sys, os, glob
import string
from numpy import *
from datetime import datetime, timedelta
import time

In the 2.4 version, I change nmnpy to Numeric



More information about the Python-list mailing list