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 "<stdin>", line 1, in ?
File "<stdin>", line 3, in __getitem__
TypeError: descriptor '__getitem__' requires a 'tuple' object but
received a 'int'
What Python are you using? On Python 2.4:
>>> class MyTuple(tuple):
... def __getitem__(self, name):
... return tuple.__getitem__(self, name)
...
>>> data = (1,2,3,4,5)
>>> t = MyTuple(data)
>>> t[0]
1
Steve
--
http://mail.python.org/mailman/listinfo/python-list