This syntax basically allows to put any code from functions into comprehensions. This enables people to write fewer functions at the cost of more complex comprehensions. But functions are a good idea indeed:
* They have a name and from that name it should be clear what that function does without having to look at the implementation.
* Functions can have documentation to provide more information about their behaviour.
* Functions have meaningful arguments possibly with type annotations that make it clear what input and output of that operation is.
* Functions can be reused.
* Functions can be tested.
With that extended comprehension syntax you'll loose all of the above benefits. Since people can put arbitrary complex code into the comprehensions this puts a burden at whoever has to read the code.
As for your first example this is already possible via
[stripped for line in lines if (stripped :=
line.strip())]
The matrix example is already pretty complex, and the comprehension difficult to read.
Plus for simple comprehensions you have now to ways to write them:
[f(x) for x in stuff]
[for x in stuff: f(x)]
I think the first version is much better because you can see immediately what the resulting list contains: f(x) objects. In the second version you have to reach the end of the comprehension to get that information and the `for x in` part is not really interesting.