[issue13549] Incorrect nested list comprehension documentation

2011-12-13 Thread Ezio Melotti
Ezio Melotti added the comment: Fixed. On a side note, using: >>> [x, x**2 for x in range(6)] File "", line 1 [x, x**2 for x in range(6)] ^ SyntaxError: invalid syntax In the 3.x docs seems to break the hightlight. With 'File "", line 1, in ?' the highlight works fine, so t

[issue13549] Incorrect nested list comprehension documentation

2011-12-13 Thread Roundup Robot
Roundup Robot added the comment: New changeset 132158b287d7 by Ezio Melotti in branch '2.7': #13549: improve tutorial section about listcomps. http://hg.python.org/cpython/rev/132158b287d7 New changeset ad5c70296c7b by Ezio Melotti in branch '3.2': #13549: improve tutorial section about listcom

[issue13549] Incorrect nested list comprehension documentation

2011-12-10 Thread Ezio Melotti
Changes by Ezio Melotti : Added file: http://bugs.python.org/file23901/issue13549-3-py32.diff ___ Python tracker ___ ___ Python-bugs-list mail

[issue13549] Incorrect nested list comprehension documentation

2011-12-10 Thread Ezio Melotti
Ezio Melotti added the comment: Having both is fine. I just noticed that the 3.2 docs are different[0], so I tried to merge them: 3.2 says: """ List comprehensions provide a concise way to create lists from sequences. Common applications are to make lists where each element is the result of s

[issue13549] Incorrect nested list comprehension documentation

2011-12-09 Thread Terry J. Reedy
Terry J. Reedy added the comment: Showing both was the intent of my comment. Since I am about 60:40 on that, I was and am willing for you, having grabbed and pushed the issue, to drop the half-expanded version if you thought it better. With or without, we have improved this section. But I st

[issue13549] Incorrect nested list comprehension documentation

2011-12-09 Thread Ezio Melotti
Ezio Melotti added the comment: In the first patch I included this example: + >>> swapped = [] + >>> for i in [0, 1, 2]: + ... swapped.append([row[i] for row in mat]) + ... + >>> print swapped + [[1, 4, 7], [2, 5, 8], [3, 6, 9]] Because I applied the following transformation wit

[issue13549] Incorrect nested list comprehension documentation

2011-12-08 Thread Terry J. Reedy
Terry J. Reedy added the comment: v.2 looks great to me. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: ht

[issue13549] Incorrect nested list comprehension documentation

2011-12-08 Thread Ezio Melotti
Changes by Ezio Melotti : Added file: http://bugs.python.org/file23885/issue13549-2.diff ___ Python tracker ___ ___ Python-bugs-list mailing l

[issue13549] Incorrect nested list comprehension documentation

2011-12-08 Thread Terry J. Reedy
Terry J. Reedy added the comment: Comments: 1. The first sentence is a bit too opinionated for my taste. Consider: map(f, seq) [f(x) for x in seq] The map is *more* concise, by 8 chars, than the list comp and, in *my* opinion, clearer and easier to read without the extra boilerplate and extr

[issue13549] Incorrect nested list comprehension documentation

2011-12-08 Thread Ezio Melotti
Ezio Melotti added the comment: > - I’d recommend a few whitespace beautifications, > like in ``for x in [1,2,3]`` and ``range(1,6)``. Leaving the space out in [1,2,3] makes the expression a bit more readable IMHO*. > I think there is an example that makes that line more > understandable, but

[issue13549] Incorrect nested list comprehension documentation

2011-12-08 Thread Éric Araujo
Éric Araujo added the comment: 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

[issue13549] Incorrect nested list comprehension documentation

2011-12-08 Thread Ezio Melotti
Changes by Ezio Melotti : -- assignee: docs@python -> ezio.melotti keywords: +patch nosy: +eric.araujo, terry.reedy stage: needs patch -> commit review Added file: http://bugs.python.org/file23882/issue13549.diff ___ Python tracker

[issue13549] Incorrect nested list comprehension documentation

2011-12-08 Thread Ezio Melotti
Ezio Melotti added the comment: This section could be clearer imho. First of all there's nothing special about "nested" list comprehensions. In [expr for elem in seq], expr might be any expression -- including a listcomp. As with any other expression, the nested listcomp will be executed for

[issue13549] Incorrect nested list comprehension documentation

2011-12-08 Thread Mark Dickinson
Mark Dickinson added the comment: Mind you, I'm not at all sure about that use of 'apprehension'... -- ___ Python tracker ___ ___ Pyt

[issue13549] Incorrect nested list comprehension documentation

2011-12-08 Thread Mark Dickinson
Mark Dickinson added the comment: Isn't the documentation that you refer to about *nested* list comprehensions, rather than list comprehensions with multiple 'for' clauses? E.g.,: [number for row in matrix for number in row] is not a nested list comprehension: it's merely a list compreh

[issue13549] Incorrect nested list comprehension documentation

2011-12-07 Thread Matt Long
New submission from Matt Long : The description of nesting list comprehensions in section 5.1.5 of the main Python tutorial (http://docs.python.org/tutorial/datastructures.html#nested-list-comprehensions) is misleading at best and arguably incorrect. Where it says "To avoid apprehension when