How to slice a deque? [duplicate]
This question already has an answer here: Use slice notation with collections.deque 6 answers I've changed some code that used a list to using a deque. I can no longer slice into it, as I get the error: TypeError: sequence index must be integer, not 'slice' Here's a REPL that shows the problem. >>> import collections >>> d = collections.deque() >>> for i in range(3): ... d.append(i) ... >>> d deque([0, 1, 2]) >>> d[2:] Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: sequence index must be integer, not 'slice' So, is there a workaround to support slicing into