Skip to content

Commit

Permalink
Update collections.rst (#182)
Browse files Browse the repository at this point in the history
Provided clear programmatic example of how deque extending does pop values on the other side when maxlen limit is reached
  • Loading branch information
jpastuszuk authored and yasoob committed Nov 30, 2018
1 parent 49d685b commit c20b5a8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions collections.rst
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,15 @@ example so here you go:

.. code:: python
d = deque(maxlen=30)
d = deque([0, 1, 2, 3, 5], maxlen=5)
print(d)
# Output: deque([0, 1, 2, 3, 5], maxlen=5)
d.extend([6])
print(d)
#Output: deque([1, 2, 3, 5, 6], maxlen=5)
Now whenever you insert values after 30, the leftmost value will be
Now whenever you insert values after 5, the leftmost value will be
popped from the list. You can also expand the list in any direction with
new values:

Expand Down

0 comments on commit c20b5a8

Please sign in to comment.