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: source/modules/Comprehensions.rst
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -88,7 +88,7 @@ Comprehensions and map()
88
88
89
89
Comprehensions are another way of expressing the "map" pattern from functional programming.
90
90
91
-
Python does have a ``map()`` function, which pre-dates comprehensions. But it does much of the same things -- and most folks think comprehensions are the more "Pythonic" way to do it. And there is nothing that can be expressed with ``map()`` that cannot be done with a comprehension. IF youare not familiar with ``map()``, you can saftly skip this, but if you are:
91
+
Python does have a ``map()`` function, which pre-dates comprehensions. But it does much of the same things -- and most folks think comprehensions are the more "Pythonic" way to do it. And there is nothing that can be expressed with ``map()`` that cannot be done with a comprehension. If you are not familiar with ``map()``, you can safely skip this, but if you are:
92
92
93
93
.. code-block:: python
94
94
@@ -100,7 +100,7 @@ is the same as:
100
100
101
101
[a_function(item), for item in an_iterable]
102
102
103
-
In this case, the comprehension is a tad wordier than ``map()``. BUt comprehensions really shine when you do'nt already have a handy function to pass to map:
103
+
In this case, the comprehension is a tad wordier than ``map()``. But comprehensions really shine when you don't already have a handy function to pass to map:
104
104
105
105
.. code-block:: python
106
106
@@ -144,7 +144,7 @@ This kind of "filtering" loop can be achieved by adding a conditional to the com
144
144
145
145
new_list = [expr for var in a_list if something_is_true]
146
146
147
-
This is expressing the "filter" pattern and the "map" pattern at the same time -- one reason I like the comprehension sytax so much.
147
+
This is expressing the "filter" pattern and the "map" pattern at the same time -- one reason I like the comprehension syntax so much.
148
148
149
149
150
150
.. rubric:: Examples:
@@ -477,4 +477,4 @@ Once you've got the hang of it, you may want to read this so you don't overdo it
0 commit comments