2015-02-27 15:16:35 -05:00
|
|
|
try:
|
|
|
|
bytearray()[:] = bytearray()
|
|
|
|
except TypeError:
|
|
|
|
print("SKIP")
|
|
|
|
import sys
|
|
|
|
sys.exit()
|
|
|
|
|
|
|
|
# test slices; only 2 argument version supported by Micro Python at the moment
|
|
|
|
x = bytearray(range(10))
|
|
|
|
|
|
|
|
# Assignment
|
|
|
|
l = bytearray(x)
|
|
|
|
l[1:3] = bytearray([10, 20])
|
|
|
|
print(l)
|
|
|
|
l = bytearray(x)
|
|
|
|
l[1:3] = bytearray([10])
|
|
|
|
print(l)
|
|
|
|
l = bytearray(x)
|
|
|
|
l[1:3] = bytearray()
|
|
|
|
print(l)
|
|
|
|
l = bytearray(x)
|
|
|
|
#del l[1:3]
|
|
|
|
print(l)
|
|
|
|
|
|
|
|
l = bytearray(x)
|
|
|
|
l[:3] = bytearray([10, 20])
|
|
|
|
print(l)
|
|
|
|
l = bytearray(x)
|
|
|
|
l[:3] = bytearray()
|
|
|
|
print(l)
|
|
|
|
l = bytearray(x)
|
|
|
|
#del l[:3]
|
|
|
|
print(l)
|
|
|
|
|
|
|
|
l = bytearray(x)
|
|
|
|
l[:-3] = bytearray([10, 20])
|
|
|
|
print(l)
|
|
|
|
l = bytearray(x)
|
|
|
|
l[:-3] = bytearray()
|
|
|
|
print(l)
|
|
|
|
l = bytearray(x)
|
|
|
|
#del l[:-3]
|
|
|
|
print(l)
|
2015-03-25 19:10:09 -04:00
|
|
|
|
|
|
|
# slice assignment that extends the array
|
|
|
|
b = bytearray(2)
|
|
|
|
b[2:] = bytearray(10)
|
|
|
|
print(b)
|