Roundup Robot devn...@psf.upfronthosting.co.za 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:
Ezio Melotti ezio.melo...@gmail.com added the comment:
Fixed.
On a side note, using:
[x, x**2 for x in range(6)]
File stdin, 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 stdin, line 1, in ?' the
Ezio Melotti ezio.melo...@gmail.com 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
Changes by Ezio Melotti ezio.melo...@gmail.com:
Added file: http://bugs.python.org/file23901/issue13549-3-py32.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13549
___
Ezio Melotti ezio.melo...@gmail.com 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
Terry J. Reedy tjre...@udel.edu 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
Mark Dickinson dicki...@gmail.com 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
Mark Dickinson dicki...@gmail.com added the comment:
Mind you, I'm not at all sure about that use of 'apprehension'...
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13549
___
Ezio Melotti ezio.melo...@gmail.com 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
Changes by Ezio Melotti ezio.melo...@gmail.com:
--
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
Éric Araujo mer...@netwok.org 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
Ezio Melotti ezio.melo...@gmail.com 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
Terry J. Reedy tjre...@udel.edu 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
Changes by Ezio Melotti ezio.melo...@gmail.com:
Added file: http://bugs.python.org/file23885/issue13549-2.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13549
___
Terry J. Reedy tjre...@udel.edu added the comment:
v.2 looks great to me.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13549
___
___
New submission from Matt Long m...@crocodoc.com:
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
16 matches
Mail list logo