[Python-Dev] Is PEP 572 really the most effective way to solve the problems it's targeting?
INADA Naoki
songofacandy at gmail.com
Thu Apr 26 22:15:20 EDT 2018
On Fri, Apr 27, 2018 at 10:52 AM Paul G <paul at ganssle.io> wrote:
> Rust has a few syntactic ways to accomplish the same thing, though. I
think match expressions are used for the equivalent of conditionals that
carry the condition value into the body of the expression, and all blocks
return the result of the last statement, so you can do things like:
> let mut x;
> while { x = foo(); x } {
> bar(x);
> }
Go is similar to Python; it's doesn't allow assignment in expression.
And Go has similar syntax like above;
for x := foo(); x {
bar(x)
}
if err := baz(); err != nil {
return err
}
I like Go and I think this syntax can be ported to Python.
But it help only if/while statements. It doesn't help list comprehension.
And Go doesn't have list comprehension.
More information about the Python-Dev
mailing list