Skip to content

Commit 7743364

Browse files
author
hartsantler
committed
dart backend: __setslice__ list[ n:n ] = iterable
1 parent 3ab21b1 commit 7743364

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

pythonjs/runtime/dart_builtins.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,18 @@ def __getslice__(self, start, stop, step):
8282
return list( a.sublist(start, stop) )
8383

8484

85+
def __setslice__(self, start, stop, step, items):
86+
if start == null: start = 0
87+
if stop == null: stop = self[...].length
88+
stop -= start
89+
while stop != 0:
90+
self[...].removeAt(start)
91+
stop -= 1
92+
if instanceof(items, String):
93+
items = items.split('')
94+
self[...].insertAll(start, items)
95+
96+
8597
def __add__(self, other):
8698
self[...].addAll( other[...] )
8799
return self

regtests/list/set_slice.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ def main():
55
a = list(range(10))
66
a[ 2:4 ] = 'XXXY'
77

8+
#if BACKEND=='DART':
9+
# print(a[...])
10+
#else:
11+
# print(a)
12+
813
TestError( a[0]==0 )
914
TestError( a[1]==1 )
1015

0 commit comments

Comments
 (0)