Message149039
I welcome improvements to this part of the docs. Nested list comps had me quite confused at first: I had to write and execute them to understand how it worked. So, the patch looks good to me. Remarks:
- I’d recommend a few whitespace beautifications, like in ``for x in [1,2,3]`` and ``range(1,6)``.
- You changed “If the expression would evaluate to a tuple, it must be parenthesized” to “If the expression is a tuple (e.g. the ``(x, y)`` +in this example), it must be parenthesized”, I guess because either the concept that an expression evaluates to something is (a) incorrect or (b) not appropriate at this stage of the tutorial. I think there is an example that makes that line more understandable, but it’s in the section about tuples, not here in the listcomp section; you may or may not want to improve that too.
- +1 for the removal of the half-joking half-recommendation not to use nested list comps (“If you've got the stomach for it, list comprehensions can be nested. They are a powerful tool but -- like all powerful tools -- they need to be used carefully, if at all.”).
- Maybe a link to the itertools module is appropriate (either after the combinations example, or after the link to the built-in zip function). |
|
Date |
User |
Action |
Args |
2011-12-08 16:31:54 | eric.araujo | set | recipients:
+ eric.araujo, terry.reedy, mark.dickinson, ezio.melotti, docs@python, mattlong |
2011-12-08 16:31:54 | eric.araujo | set | messageid: <1323361914.33.0.746658220089.issue13549@psf.upfronthosting.co.za> |
2011-12-08 16:31:53 | eric.araujo | link | issue13549 messages |
2011-12-08 16:31:53 | eric.araujo | create | |
|