1.1 --- a/lib/__builtins__/sequence.py Thu Dec 01 23:06:26 2016 +0100
1.2 +++ b/lib/__builtins__/sequence.py Thu Dec 01 23:27:23 2016 +0100
1.3 @@ -49,7 +49,7 @@
1.4 # Handle slices separately.
1.5
1.6 elif _isinstance(index, slice):
1.7 - return self.__getslice__(index.start, index.end)
1.8 + return self.__getslice__(index.start, index.end, index.step)
1.9
1.10 # No other kinds of objects are supported as indexes.
1.11
1.12 @@ -77,9 +77,16 @@
1.13 else:
1.14 raise TypeError()
1.15
1.16 - def __getslice__(self, start, end=None):
1.17 + def __getslice__(self, start, end=None, step=1):
1.18
1.19 - "Return a slice starting from 'start', with the optional 'end'."
1.20 + """
1.21 + Return a slice of the sequence starting from the 'start' index, ending
1.22 + before the optional 'end' (or at the end of the sequence), and providing
1.23 + items at the frequency given by 'step' (with a default step of 1).
1.24 + """
1.25 +
1.26 + if step == 0:
1.27 + raise ValueError(step)
1.28
1.29 length = self.__len__()
1.30
1.31 @@ -101,9 +108,9 @@
1.32
1.33 result = []
1.34
1.35 - while start < end:
1.36 + while step > 0 and start < end or step < 0 and start > end:
1.37 result.append(self.__get_single_item__(start))
1.38 - start += 1
1.39 + start += step
1.40
1.41 return result
1.42