[docs] Extra list comprehension example
Alexander Belopolsky
alexander.belopolsky at gmail.com
Mon Nov 15 17:22:01 CET 2010
> Ruud Althuizen wrote:
> I just read this line from section 5.1.5: "To avoid apprehension when
> nesting list comprehensions, read from right to left." I must've read
> over that bit the first thousand times. Adding the example
> probably makes it more obvious.
I agree, this maxim, while appropriate for the tutorial, can be better
presented. In the current version, the following paragraph is stuck
between a nested list comprehension example and an equivalent nested
for loop:
"""
Special care has to be taken for the nested list comprehension:
To avoid apprehension when nesting list comprehensions, read from
right to left.
"""
Other than rather subtle indentation, there is nothing to suggest that
"To avoid apprehension ..." is an aphorism and that "apprehension" is
not a Python term unknown to user. (The word "apprehension" rhymes
well with "comprehension," but may lead to confusion if understood to
mean "understanding; grasp." If "apprehension" is taken to mean
"arrest," the dictum may or may not be helpful depending on the
reader's sense of humor.)
I think it would be best to move the maxim either to the paragraph
before the "mat" example or to a paragraph after the equivalent
for-loop. The text should explain the mnemonic nature of the rule and
what "read from right to left" means in the "mat" example.
Nested list comprehensions should also be contrasted to list
comprehensions with multiple for clauses.
More information about the docs
mailing list