Re: Simple question about Python lists

2008-11-17 Thread Eric
On Nov 11, 7:31 pm, Ben Finney <[EMAIL PROTECTED]> wrote: > Steven D'Aprano <[EMAIL PROTECTED]> writes: > > On Wed, 12 Nov 2008 10:08:45 +1100, Ben Finney wrote: > > > >Eric<[EMAIL PROTECTED]> writes: > > >> In MATLAB, if  I just want the first, fifth  and eighth element I > > >> might do something

Re: Simple question about Python lists

2008-11-12 Thread Scott David Daniels
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 <[EMAIL PROTECTED]> replied: b = [a[i] for i in [1, 5, 8]] To which Eric said: Thanks! It makes sense, but in this cas

Re: Simple question about Python lists

2008-11-11 Thread Ben Finney
Steven D'Aprano <[EMAIL PROTECTED]> writes: > On Wed, 12 Nov 2008 10:08:45 +1100, Ben Finney wrote: > > > Eric <[EMAIL PROTECTED]> writes: > >> In MATLAB, if I just want the first, fifth and eighth element I > >> might do something like this: > >> > >> b = a([1 5 8]); > > > > Yes: the above c

Re: Simple question about Python lists

2008-11-11 Thread Robert Kern
Steven D'Aprano wrote: On Wed, 12 Nov 2008 10:08:45 +1100, Ben Finney wrote: Eric <[EMAIL PROTECTED]> writes: I'm learning Python (while coming from MATLAB). One question I have is that if I have a list with say 8 elements, and I want just a few of them how do I select them out. In MATLAB, if

Re: Simple question about Python lists

2008-11-11 Thread Steven D'Aprano
On Wed, 12 Nov 2008 10:08:45 +1100, Ben Finney wrote: > Eric <[EMAIL PROTECTED]> writes: > >> I'm learning Python (while coming from MATLAB). One question I have is >> that if I have a list with say 8 elements, and I want just a few of >> them how do I select them out. In MATLAB, if I just want t

Re: Simple question about Python lists

2008-11-11 Thread Ben Finney
Eric <[EMAIL PROTECTED]> writes: > I'm learning Python (while coming from MATLAB). One question I have is > that if I have a list with say 8 elements, and I want just a few of > them how do I select them out. In MATLAB, if I just want the first, > fifth and eighth element I might do something like

Re: Simple question about Python lists

2008-11-11 Thread Robert Kern
Eric wrote: On Nov 11, 1:51 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: On Tue, 11 Nov 2008 11:47:53 -0800, Eric wrote: I'm learning Python (while coming from MATLAB). One question I have is that if I have a list with say 8 elements, and I want just a few of them how do I select the

Re: Simple question about Python lists

2008-11-11 Thread Eric
On Nov 11, 1:51 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Tue, 11 Nov 2008 11:47:53 -0800, Eric wrote: > > I'm learning Python (while coming from MATLAB). One question I have is > > that if I have a list with say 8 elements, and I want just a few of them > > how do I select them

Re: Simple question about Python lists

2008-11-11 Thread Robert Kern
Guilherme Polo wrote: On Tue, Nov 11, 2008 at 5:47 PM, Eric <[EMAIL PROTECTED]> wrote: I'm learning Python (while coming from MATLAB). One question I have is that if I have a list with say 8 elements, and I want just a few of them how do I select them out. In MATLAB, if I just want the first, fi

Re: Simple question about Python lists

2008-11-11 Thread Guilherme Polo
On Tue, Nov 11, 2008 at 5:47 PM, Eric <[EMAIL PROTECTED]> wrote: > I'm learning Python (while coming from MATLAB). One question I have is > that if I have a list with say 8 elements, and I want just a few of > them how do I select them out. In MATLAB, if I just want the first, > fifth and eighth el

Re: Simple question about Python lists

2008-11-11 Thread Marc 'BlackJack' Rintsch
On Tue, 11 Nov 2008 11:47:53 -0800, Eric wrote: > I'm learning Python (while coming from MATLAB). One question I have is > that if I have a list with say 8 elements, and I want just a few of them > how do I select them out. In MATLAB, if I just want the first, fifth and > eighth element I might do