[Python-ideas] Re: multidimensional lists

2020-07-08 Thread Hans Ginzel
On Wed, Jul 08, 2020 at 11:32:32PM +1000, Chris Angelico wrote: >>> T = [[11, 12, 5, 2], [15, 6, 10], [10, 8, 12, 5], [12, 15, 8, 6]] >>> print(T[1, 2]) TypeError: list indices must be integers or slices, not tuple If you want a helper function, it's not hard to write it: def fetch(collection,

[Python-ideas] Re: multidimensional lists

2020-07-08 Thread Dominik Vilsmeier
On 08.07.20 15:09, Hans Ginzel wrote: Why not to allow tuple as a list index? T = [[11, 12, 5, 2], [15, 6, 10], [10, 8, 12, 5], [12, 15, 8, 6]] print(T[1][2]) 10 print(T[1, 2]) Traceback (most recent call last):   File "", line 1, in TypeError: list indices must be integers or slices, not

[Python-ideas] Re: multidimensional lists

2020-07-08 Thread Chris Angelico
On Wed, Jul 8, 2020 at 11:18 PM Hans Ginzel wrote: > > Why not to allow tuple as a list index? > > >>> T = [[11, 12, 5, 2], [15, 6, 10], [10, 8, 12, 5], [12, 15, 8, 6]] > >>> print(T[1][2]) > 10 > >>> print(T[1, 2]) > Traceback (most recent call last): >File "", line 1, in > TypeError: list i