Simple question about Python lists

Scott David Daniels Scott.Daniels at Acm.Org
Wed Nov 12 22:08:49 CET 2008

Eric wrote:
> ... In MATLAB, if I just want the first, fifth and eighth element I
> might do something like this:   b = a([1 5 8]);

On Nov 11, 1:51 pm, Marc 'BlackJack' Rintsch <bj_... at> replied:
>> b = [a[i] for i in [1, 5, 8]]

To which Eric said:
> Thanks! It makes sense, but in this case MATLAB seems easier and no
> less readable. That said, I know better than for a newbie like me to
> question syntax issues.

If you are using numpy, you may find found the following link useful:

--Scott David Daniels
Scott.Daniels at Acm.Org

More information about the Python-list mailing list