> Why is this?
It should work.Are you using an old version of Python?
--
http://mail.python.org/mailman/listinfo/python-list
VanL wrote:
Why is this?
>>> class MyTuple(tuple):
... def __getitem__(self, name):
... return tuple.__getitem__(self, name)
...
>>> data = (1,2,3,4,5)
>>> t = MyTuple(data)
>>> t[0]
Traceback (most recent call last):
File "", line 1, in ?
File "", line 3, in __getitem__
TypeErr
I forgot to mention:
>>> mytup=("fred","barney")
>>> tuple.__getitem__(mytup,0)
'fred'
On Tuesday 21 December 2004 09:41 am, VanL wrote:
> Hello,
>
> Why is this?
>
> >>> class MyTuple(tuple):
>
> ... def __getitem__(self, name):
> ... return tuple.__getitem__(self, name)
> ...
>
>
I don't think the tuple name is working as you expect. I don't know of any
reason to redefine "__getitem__()" the way you have done:
>>> class MyTuple(tuple):
... pass
...
>>> data = (1,2,3,4,5)
>>> t = MyTuple(data)
>>> t[0]
1
>>> tuple
>>> tuple.__getitem__
>>> tuple.__getitem__(0)
Tracebac