In [1]:
from collections import deque
In [2]:
d = deque(['l', 'm', 'n'], 3)
print(d)
In [3]:
d.append('o')
print(d)
In [4]:
d.appendleft('l')
print(d)
In [5]:
d.extend(['o', 'p'])
print(d)
In [6]:
d.extendleft(['m', 'l'])
print(d)
In [7]:
# d.insert(0, 'XXX')
# IndexError: deque already at its maximum size
In [8]:
print(d.pop())
In [9]:
print(d)
In [10]:
d.insert(1, 'XXX')
print(d)
In [11]:
print(d.maxlen)
In [12]:
# d.maxlen = 5
# AttributeError: attribute 'maxlen' of 'collections.deque' objects is not writable