[Numpy-discussion] Question about indexing

Keith Goodman kwgoodman@gmail....
Thu May 29 22:08:51 CDT 2008


On Thu, May 29, 2008 at 6:32 PM, Alan G Isaac <aisaac@american.edu> wrote:
> On Thu, 29 May 2008, Keith Goodman apparently wrote:
>> >>> a[[0,1]]
>> That one looks odd. But it is just shorthand for:
>> >>> a[[0,1],:]
>
>
> Do you mean that ``a[[0,1],:]`` is a more primitive
> expression than ``a[[0,1]]``?  In what sense, and does it
> ever matter?
>
> Is ``a[[0,1]]`` completely equivalent to ``a[[0,1],...]``
> and ``a[[0,1],:]``?

I can see how the difference between

a[0,1]
a[[0,1]]

is not obvious at first, especially if you come from octave/matlab.
The first example has an obvious i and j. But the second example
doesn't. So I tried to point out that i=[0,1] and j=:.


More information about the Numpy-discussion mailing list