Re: How to access elemenst in a list of lists?

2011-05-10 Thread Algis Kabaila
On Tuesday 10 May 2011 11:25:59 Terry Reedy wrote: On 5/9/2011 8:44 PM, Algis Kabaila wrote: The method of double indexing in the manner a[i][j] for the (i, j) -th element of multi-dimensional array is well known and widely used. But how to enable the standard matrix notation a[i, j]

Re: How to access elemenst in a list of lists?

2011-05-10 Thread Algis Kabaila
On Tuesday 10 May 2011 17:22:42 Algis Kabaila wrote: On Tuesday 10 May 2011 11:25:59 Terry Reedy wrote: On 5/9/2011 8:44 PM, Algis Kabaila wrote: The method of double indexing in the manner a[i][j] for the (i, j) -th element of multi-dimensional array is well known and widely used.

Re: How to access elemenst in a list of lists?

2011-05-10 Thread Terry Reedy
On 5/10/2011 3:22 AM, Algis Kabaila wrote: On Tuesday 10 May 2011 11:25:59 Terry Reedy wrote: class listwrap: def __init__(self, lis): self._list = lis def __getitem__(self, dex): i,j = dex return self._list[i][j] # __setitem__: exercise for reader l =

Re: How to access elemenst in a list of lists?

2011-05-10 Thread Algis Kabaila
On Tuesday 10 May 2011 17:44:44 Terry Reedy wrote: On 5/10/2011 3:22 AM, Algis Kabaila wrote: On Tuesday 10 May 2011 11:25:59 Terry Reedy wrote: class listwrap: def __init__(self, lis): self._list = lis def __getitem__(self, dex): i,j = dex return

Re: How to access elemenst in a list of lists?

2011-05-09 Thread Antonio CHESSA
Just learning python. I can see that I can address an individual element of a list of lists by doing something like: row = list[5] element = row[3] But is there a way to directly address an entry in a single statement? Thanks for any help. Regards Chris Roy-Smith suppose you have a list like

Re: How to access elemenst in a list of lists?

2011-05-09 Thread Terry Reedy
On 5/9/2011 4:25 AM, Antonio CHESSA wrote: apple = [[a,b,c],[1,2,3,4,5,6],[antony,max,sandra,sebastian]] apple[0] = [a,b,c] apple[1] = [1,2,3,4,5,6] apple[2] = [antony,max,sandra,sebastian] apple[0][1] = b apple[2][3] = sebastian to view all videos in a loop so you can set: for i in

Re: How to access elemenst in a list of lists?

2011-05-09 Thread Algis Kabaila
On Tuesday 10 May 2011 05:24:16 Terry Reedy wrote: On 5/9/2011 4:25 AM, Antonio CHESSA wrote: apple = [[a,b,c],[1,2,3,4,5,6],[antony,max,sandra,seb astian]] for j in range (len(apple[i])): print apple[i][j] While this illustrate double indexing, it can be simplified to

Re: How to access elemenst in a list of lists?

2011-05-09 Thread Terry Reedy
On 5/9/2011 8:44 PM, Algis Kabaila wrote: The method of double indexing in the manner a[i][j] for the (i, j) -th element of multi-dimensional array is well known and widely used. But how to enable the standard matrix notation a[i, j] in Python 3.2 in the manner of numpy (and other matrix

How to access elemenst in a list of lists?

2011-05-08 Thread Chris Roy-Smith
Just learning python. I can see that I can address an individual element of a list of lists by doing something like: row = list[5] element = row[3] But is there a way to directly address an entry in a single statement? Thanks for any help. Regards Chris Roy-Smith --

Re: How to access elemenst in a list of lists?

2011-05-08 Thread Chris Angelico
On Mon, May 9, 2011 at 1:15 PM, Chris Roy-Smith chris_roysmith.noth...@internode.on.net wrote: Just learning python. I can see that I can address an individual element of a list of lists by doing something like: row = list[5] element = row[3] But is there a way to directly address an entry

Re: How to access elemenst in a list of lists?

2011-05-08 Thread James Mills
On Mon, May 9, 2011 at 1:23 PM, Chris Angelico ros...@gmail.com wrote: Just learning python. I can see that I can address an individual element of a list of lists by doing something like: row = list[5] element = row[3] This is the correct approach. Here's an interactive example (tested): $