Double-ended queues, or deques, can be useful when you need to remove elements in the order : deque « Collections « Python Tutorial






from collections import deque
q = deque(range(5))
q.append(5)
q.appendleft(6)
print q
print q.pop()
print q.popleft()
print q.rotate(3)
print q
print q.rotate(-1)
print q








9.1.deque
9.1.1.Double-ended queues, or deques, can be useful when you need to remove elements in the order
9.1.2.Working with the deque Class