Steven Bethard wrote:
> [EMAIL PROTECTED] wrote:
> > from Numeric import *
> >
> > # Initialize the 32x16 global array to zeros
> > tbl = zeros((32, 16)
> >
> > def getValue( value):
> >     data = test(value)
> >     c1 = data[0]
> >     c2 = data[1]
> >     print tbl[c1, c2]
> >
> > def test( value):
> >     t1 = 0x0
> >     t2 = 0x1
> >     return tbl[t1, t2]
>
> In test, tbl[0x0, 0x1] is just going to give you a single element of
> tbl, in this case a 0.  So data is a 0.  data[0] and data[1] doesn't
> really make much sense.  Is this the code you actually get the
> IndexError with?  I'm using numarray, not Numeric, and I know there
are
> some differences, but the code above doesn't give me an IndexError:
>
> py> import numarray as na
> py> tbl = na.zeros((32, 16))
> py> def get_value():
> ...     data = test()
> ...     c1 = data[0]
> ...     c2 = data[1]
> ...     print tbl[c1, c2]
> ...
> py> def test():
> ...     t1 = 0x0
> ...     t2 = 0x1
> ...     return tbl[t1, t2]
> ...
> py> get_value()
> Traceback (most recent call last):
>    File "<interactive input>", line 1, in ?
>    File "<interactive input>", line 3, in get_value
> TypeError: unsubscriptable object
>
> STeVe

What i was intending to do is return a list with row and column values.

data[0] and data[1] are the list values i get from test.

Whats the best way to read these row and column values in function
get_value() when i return the list (return tbl[t1, t2])

Thanks,
-SB

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to