Skip to content

Commit c54553f

Browse files
committed
Create deque instance directly from range object.
Explicitly iterating over the range object in the form of a list comprehension (BTW, a generator expression here would be more appropriate, and easier to read) without transforming or filtering elements is unnecessary, so the range object can be used to directly feed its values to the deque on instantiation.
1 parent 4473bb3 commit c54553f

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

collections.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ You can pop values from both sides of the deque:
158158

159159
.. code:: python
160160
161-
d = deque([i for i in range(5)])
161+
d = deque(range(5))
162162
print(len(d))
163163
# Output: 5
164164

0 commit comments

Comments
 (0)