
I'm sorry for reposting, but this message got stuck in moderation approval for 5 days so I figured I should try again.
I'd like to propose extending the for statement to include conditionals akin to comprehensions in order to simplify for loop statements:
`for .. in .. if ..:`
E.g.
for x in y if x in c: some_op(x)
which is functionally equivalent as
for x in y: if x not in c: continue some_op(x)
The `for .. in .. if` syntax is a well-known construct from list comprehension syntax [1]. Other alternative ways to do this with list comprehension is:
for x in (a for a in y if c):
or
it = (a for a in y if c) for x in it:
Without having examined all use cases, I believe the same syntax should be applied this syntax as for asynchronous comprehensions.
[1] PEP 202 - List Comprehensions [2] PEP 530 - Asynchronous Comprehensions
Best regards, Svein Seldal