Access elements from nested tuples
jss
jss at coders.de
Mon Sep 4 17:15:18 EDT 2006
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]
------------------------------------------------------------
File "<ipython console>", line 1
k.[1]
^
SyntaxError: invalid syntax
Note that:
In [7]: type(t[1])
Out[7]: <type 'tuple'>
just as t.
hth,
jss
More information about the Python-list
mailing list