Commit 8578308
authored
Doc: clarify distinction between nested listcomps and multi-for listcomps
In section 5.1.3, the flatten example uses a single list comprehension
with two `for` clauses. In section 5.1.4, the actual nested list
comprehension (a comprehension whose expression is itself a
comprehension) is introduced.
The current wording creates two problems:
1. The flatten example in 5.1.3 has no label distinguishing it from
a "nested" comprehension, so readers may already think they've seen
nesting before reaching 5.1.4.
2. Section 5.1.4 opens with "As we saw in the previous section...",
implying the two constructs are the same idea continued, rather
than two distinct concepts.
This commit:
- Adds "single ... with two 'for' clauses" to the flatten comment in
5.1.3 to preemptively distinguish it.
- Rewrites the opening sentence of the 5.1.4 explanation to explicitly
contrast the two constructs and clarify what makes a list
comprehension truly "nested".1 parent c6f7368 commit 8578308
1 file changed
Lines changed: 7 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
265 | 265 | | |
266 | 266 | | |
267 | 267 | | |
268 | | - | |
| 268 | + | |
269 | 269 | | |
270 | 270 | | |
271 | 271 | | |
| |||
296 | 296 | | |
297 | 297 | | |
298 | 298 | | |
299 | | - | |
300 | | - | |
301 | | - | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
302 | 305 | | |
303 | 306 | | |
304 | 307 | | |
| |||
0 commit comments