kuroko/test/testSlicers.krk

35 lines
634 B
Python
Raw Normal View History

def test(a):
print(a[::])
print(a[::-1])
print(a[::2])
print(a[::-2])
print(a[1:2])
print(a[1:7:3])
print(a[5::-3])
test([1,2,3,4,5,6,7,8,9,10,11,12,13])
test("こんにちは、みんなさま。クロコへようこそ。")
class SlicerTester:
def __getitem__(self, indexer):
print(indexer)
SlicerTester()[::]
SlicerTester()[::-1]
SlicerTester()[1:2:3]
SlicerTester()['a':'b':'c']
SlicerTester()[:]
SlicerTester()[:'end']
SlicerTester()['start':]
SlicerTester()[:'end':]
SlicerTester()[:'end':'step']
SlicerTester()['start'::'step']
SlicerTester()[1:2,3:4]
SlicerTester()[1:2:3,::4]