You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/writing/style.rst
+7-6Lines changed: 7 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -597,7 +597,8 @@ Python will lose track of its current position.
597
597
if i >4:
598
598
a.remove(i)
599
599
600
-
Python has standard ways of filtering lists, but there are several things you need to consider
600
+
Python has a few standard ways of filtering lists.
601
+
You will need to consider
601
602
602
603
* Python 2.x vs. 3.x
603
604
* Lists vs. iterators
@@ -606,19 +607,19 @@ Python has standard ways of filtering lists, but there are several things you ne
606
607
Python 2.x vs. 3.x
607
608
::::::::::::::::::
608
609
609
-
* Starting with Python 3.0, the :py:func:`map` and :py:func:`filter` functions return an iterator instead of a list. If you really need a list, you should wrap these functions in :py:func`list` like so
610
+
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
610
612
611
613
.. code-block:: python
612
614
613
-
list(map(...))
614
615
list(filter(...))
615
616
616
-
* List comprehensions and generator expressions work the same in both 2.x and 3.x (except that comprehensions in 2.x "leak" variables into the enclosing namespace)
617
+
List comprehensions and generator expressions work the same in both 2.x and 3.x (except that comprehensions in 2.x "leak" variables into the enclosing namespace)
617
618
618
619
* comprehensions create a new list object
619
620
* generators iterate over the original list
620
621
621
-
* The filter function
622
+
The :py:func:`filter` function
622
623
623
624
* in 2.x returns a list (use itertools.ifilter if you want an iterator)
624
625
* in 3.x returns an iterator
@@ -663,7 +664,7 @@ Modifying the values in a list
663
664
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
664
665
**Bad**:
665
666
666
-
Remember that assignment never creates a new object. If 2 or more variables refer to the same list, changing one of them changes them all.
667
+
Remember that assignment never creates a new object. If two or more variables refer to the same list, changing one of them changes them all.
0 commit comments