numeric module

Terry Reedy tjreedy at udel.edu
Fri Apr 1 14:37:00 EST 2005


<shama.bell at gmail.com> wrote in message 
news:1112377090.192124.303640 at o13g2000cwo.googlegroups.com...
> What's the problem with this code? I get the following error message:

2.4 or earlier?

> File "test.py", line 26, in test
>    print tbl[wi][bi]
> IndexError: index must be either an int or a sequence

Longs are not ints; message implies that Numeric, unlike Python, does not 
allow them as indexes.

> from Numeric import *
> tbl = zeros((32, 16))
>
> def test():
>
>    val = testme()

val is never used

>    wi = crc >> 4

crc is never set, so how did this run?

>    bi = crc & 0xFL

making bi a long.  Try 0xF which should be faster anyway.

>    print wi
>    print bi
print type(wi), type(bi)
>    print tbl[wi][bi]
>
> def testme():
>    val = 0xFFFFFFL
>    val >>= 23
>    return val
>
> if __name__ == '__main__':
>    test()






More information about the Python-list mailing list