On 10/28/07, Matthieu Brucher <[EMAIL PROTECTED]> wrote: > > > Little correction, only c[(2,3)] gives me what I expect, not c[[2,3]], > > which > > > is even stranger. > > > > c[(2,3)] is the same as c[2,3] and obviously works as you expected. > > > > Well, this is not indicated in the documentation. >
This is true at the Python level and is not related to numpy. "x=c[2,3]" is equivalent to "x=c.__getitem__((2,3))". Note that the index pair is passed as a tuple. On the other hand, a single index is not passed as a tuple, but is instead passed as is. For example: "x = c[a]" gets passed as "x=c.__getitem__(a)". If 'a' happens to be '(2,3)' you get the behavior above. So, although lists and arrays can be used for "fancy-indexing", tuples cannot be since you can't tell the difference between a tuple of indices and multiple indices inside square brackets. [SNIP] -- . __ . |-\ . . [EMAIL PROTECTED]
_______________________________________________ Numpy-discussion mailing list [email protected] http://projects.scipy.org/mailman/listinfo/numpy-discussion
