Skip to content

Commit c20b5a8

Browse files
jpastuszukyasoob
authored andcommitted
Update collections.rst (yasoob#182)
Provided clear programmatic example of how deque extending does pop values on the other side when maxlen limit is reached
1 parent 49d685b commit c20b5a8

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

collections.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,15 @@ example so here you go:
216216

217217
.. code:: python
218218
219-
d = deque(maxlen=30)
219+
d = deque([0, 1, 2, 3, 5], maxlen=5)
220+
print(d)
221+
# Output: deque([0, 1, 2, 3, 5], maxlen=5)
222+
223+
d.extend([6])
224+
print(d)
225+
#Output: deque([1, 2, 3, 5, 6], maxlen=5)
220226
221-
Now whenever you insert values after 30, the leftmost value will be
227+
Now whenever you insert values after 5, the leftmost value will be
222228
popped from the list. You can also expand the list in any direction with
223229
new values:
224230

0 commit comments

Comments
 (0)