Fernando Perez wrote:
> Hi all,
>
> I was wondering if someone can help me understand why __getslice__ has been
> deprecated, yet it remains necessary to implement it for simple slices (i:j),
> while __getitem__ gets called for extended slices (i:j:k).
[...]
> def __getitem__(self,key):
> """called for single-element OR slice access"""
> if type(key) is types.SliceType:
> return Vector(list.__getitem__(self,key))
> else:
> return list.__getitem__(self,key)
I just realized that the type check is cleaner if done via
def __getitem__(self,key):
"""called for single-element OR slice access"""
if isinstance(key,slice):
return Vector(list.__getitem__(self,key))
else:
return list.__getitem__(self,key)
Still, the core of my question remains.
TIA,
f
--
http://mail.python.org/mailman/listinfo/python-list