[Python-bugs-list] [ python-Bugs-459235 ] tuple __getitem__ limited

noreply@sourceforge.net noreply@sourceforge.net
Mon, 03 Jun 2002 14:01:01 -0700


Bugs item #459235, was opened at 2001-09-06 13:11
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=459235&group_id=5470

Category: Type/class unification
Group: Python 2.2
Status: Open
Resolution: None
>Priority: 5
Submitted By: Martin v. Löwis (loewis)
Assigned to: Guido van Rossum (gvanrossum)
Summary: tuple __getitem__ limited

Initial Comment:
The __getitem__ of a tuple does not support the
extended slicing. That makes it difficult to delegate
from an object's __getitem__ to a builtin container,
which ought to work through delegating __getitem__

<pre>
class GI:
    def __getitem__(self,a):
        print a

a = GI()
a[1:2]
(1,2,3,4).__getitem__(slice(1,2,None))
</pre>

gives

slice(1, 2, None)
Traceback (most recent call last):
  File "bar.py", line 7, in ?
    (1,2,3,4).__getitem__(slice(1,2,None))


----------------------------------------------------------------------

>Comment By: Guido van Rossum (gvanrossum)
Date: 2002-06-03 17:01

Message:
Logged In: YES 
user_id=6380

See (revived) patch 400998?

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2001-09-06 14:08

Message:
Logged In: YES 
user_id=6380

This is not just the __getitem__ -- t[...] also has this
problem.
As a workaround, you can define __getslice__ or parse the
slice() object yourself.

I'll eventually get around to fixing this, but it's a bit
messy.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=459235&group_id=5470