[Python-ideas] if-statement in for-loop
Random832
random832 at fastmail.com
Fri Sep 30 12:52:57 EDT 2016
On Tue, Sep 27, 2016, at 17:36, Greg Ewing wrote:
> Erik Bray wrote:
> > Then following my own logic it
> > would be desirable to also allow the nested for loop syntax of list
> > comprehensions outside them as well.
>
> The only use for such a syntax would be to put
> an inadvisable amount of stuff on one line.
The only difference between an inadvisable amount of stuff and a
reasonable amount of stuff is the amount. Don't we already have a
recommended column limit in PEP8?
for y in range(25) for x in range(80): doesn't seem unreasonable to me;
YMMV.
Or maybe you want to put it on multiple lines, but not consuming
indentation levels:
for x in seq1 if p1(x)\
for y in seq2 if p2(y)\
for z in seq3 if p3(z):
result.append(f(x, y, z))
More information about the Python-ideas
mailing list