Skip to content

Commit dc078e1

Browse files
Cleaned up some wording
1 parent 6d8a602 commit dc078e1

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

docs/writing/style.rst

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -586,8 +586,7 @@ Filtering a list
586586

587587
**Bad**:
588588

589-
Never remove items from list while you are iterating through it.
590-
Python will lose track of its current position.
589+
Never remove items from a list while you are iterating through it.
591590

592591
.. code-block:: python
593592
@@ -597,8 +596,17 @@ Python will lose track of its current position.
597596
if i > 4:
598597
a.remove(i)
599598
599+
Don't make multiple passes through the list.
600+
601+
.. code-block:: python
602+
603+
while i in a:
604+
a.remove(i)
605+
606+
**Good**:
607+
600608
Python has a few standard ways of filtering lists.
601-
You will need to consider
609+
The approach you use depends on
602610

603611
* Python 2.x vs. 3.x
604612
* Lists vs. iterators
@@ -608,7 +616,7 @@ Python 2.x vs. 3.x
608616
::::::::::::::::::
609617

610618
Starting with Python 3.0, the :py:func:`filter` function returns an iterator instead of a list.
611-
If you really need a list, you should wrap it in :py:func:`list` like so
619+
Wrap it in :py:func:`list` if you truly need a list.
612620

613621
.. code-block:: python
614622

0 commit comments

Comments
 (0)