On Tue, Jan 27, 2015, at 13:05, Mario Figueiredo wrote: > In article <qot7fw8s3la....@ruuvi.it.helsinki.fi>, > jpiit...@ling.helsinki.fi says... > > > > If you mean literally some_predicate, then perhaps this. > > > > if some_predicate: > > for x in seq: > > handle(x) > > > > Careful. See Chris Warrick answer for the correct position of the 'if' > statement.
I think by "if you mean literally some_predicate" he was taking some_predicate as a variable [rather than an expression] that does not change during the loop. That'd be a silly thing to do in the originally posted code, though, since it'd be easier to do "[] if not some_predicate else [...]" -- https://mail.python.org/mailman/listinfo/python-list