Re: Access elements from nested tuples

2006-09-05 Thread Georg Sauthoff
On 2006-09-04, Tim Chase <[EMAIL PROTECTED]> wrote: Hi, [nested tuples] thanks - I should not post before 8 am or 10 pm ... Regards Georg Sauthoff -- http://mail.python.org/mailman/listinfo/python-list

Re: Access elements from nested tuples

2006-09-04 Thread jss
Hi Georg! In [1]: t=(1,(2,3)) > I am bit suprised, that I cannot access '3' via: > t[1].[1] # syntax error > > But t[1].__getitem__(1) works like expected. In [2]: k=t[1] In [3]: k[1] Out[3]: 3 In [4]: t[1][1] Out[4]: 3 In [5]: k.__getitem__(1) Out[5]: 3 In [6]: k.[1] ---

Re: Access elements from nested tuples

2006-09-04 Thread Tim Chase
> t = (1, (2, 3)) > > I am bit suprised, that I cannot access '3' via: > t[1].[1] # syntax error > > But t[1].__getitem__(1) works like expected. > > Why is that? What is "t"? It's a tuple. A tuple can be indexed, or you can call its __getitem__ method. Thus, the one-th element of t is eith

Access elements from nested tuples

2006-09-04 Thread Georg Sauthoff
Hi, t = (1, (2, 3)) I am bit suprised, that I cannot access '3' via: t[1].[1] # syntax error But t[1].__getitem__(1) works like expected. Why is that? Regards Georg Sauthoff -- http://mail.python.org/mailman/listinfo/python-list