See my proposal for a similar syntax for “filtered” assignment and “filtered” returns Conditional Expresion/Statements
And see this proposal to have “filtered” context managers: Conditional context manager (with foo() if bar)
I guess one of the answers you are going to get is that you can also do
for thing in (y for y in bunch_of_things if y.bar > 42):
do_something_with(thing.foo)
which of course it is not convoluted at all (filter
can also be applied here with a lambda
)
Whereas I would tend to see a slowly emerging pattern … people want to have things conditionally executed with an if
statement at the end.
My 2 cents.