[Python-bugs-list] [ python-Bugs-633152 ] list slice ass ignores subtypes of list

noreply@sourceforge.net noreply@sourceforge.net
Mon, 04 Nov 2002 00:19:59 -0800


Bugs item #633152, was opened at 2002-11-04 09:19
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=633152&group_id=5470

Category: Python Interpreter Core
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Ronald Oussoren (ronaldoussoren)
Assigned to: Nobody/Anonymous (nobody)
Summary: list slice ass ignores subtypes of list

Initial Comment:
When assigning a subtype of list to a list slice the implementation 
of slice-assignment directly accesses the list representation and 
ignores any modified accessor functions:

class MyList  (list):
    def __getitem__(self, idx):
        if idx % 2 == 0:
            return 'E'
        return 'O'

mylst = MyList()
mylst.append(1)
mylst.append(1)

lst = [ 1, 2, 3, 4]
lst [2:3] = mylst
print lst
# prints [1, 2, 1, 1, 4] I'd expect it to print [1, 2, 'E', 'O', 4 ]

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

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