[Numpy-discussion] Indexing with a list...
Sun Aug 9 01:38:01 CDT 2009
On Sat, Aug 8, 2009 at 10:09 PM, David Warde-Farley<firstname.lastname@example.org> wrote:
> On 9-Aug-09, at 12:36 AM, T J wrote:
>>>>> z = array([1,2,3,4])
> In the special case of scalar indices they're treated as if they are
> length-1 tuples. The behaviour you're seeing is the same as z.
Sure, but that wasn't my question.
I was asking about the difference between indexing with a 1-tuple (or
scalar) and with a 1-list. Naively, I guess I didn't expect there to
be a difference. Though, I can see its uses (through the z[z<3]
The dictionary example is nice in that is really highlights exactly
*how* different arrays are from python dictionaries (aside from the
obvious): since lists are unhashable, you can't index with them at
all. Yet you can index numpy arrays with lists AND the behavior is
different from if you indexed with a tuple!
>>> z = array([1,2,3])
>>> i = 
More information about the NumPy-Discussion