(Jakub, next time please trim the original post from your quote to what's necessary.)

On Wed, Jun 24, 2020 at 9:11 AM <jakub@stasiak.at> wrote:
Wow, I totally didn't see this coming, not after seeing what seems like a lot of rejected ideas on this topic (there was at least one PEP already that proposed this, right?). I have to admire the authors' determination to write such a lengthy and (from skimming it) complex and comprehensive proposal *and* providing a reference implementation on top of that, the amount of work (including internal bikeshedding) must've been substantial.

Needless to say it's +1 from my humble person, big time, and I wouldn't want the comment below to detract from that.

So, now for the one thing that makes me unhappy: the rejected idea to make it an expression. In my short experience with pattern matching, mainly in Rust, roughly half (very vague estimate) of its usefulness came from it being an expression. It's even small things like

            let i = match i {
                9 => 10,
                10 => 9,
                _ => i,
            };

and

    let mut file: Box<Write> = match filename.as_ref() {
        "-" => Box::new(io::stdout()),
        _ => Box::new(File::create(filename).expect("Cannot open file for writing")),
    };

and it adds up. I'm not sure how to approach this with Python syntax and I'll think about this, but I feel that it'd be a huge missed opportunity to not have this.

We considered it, but it simply doesn't work, for the same reason that we haven't been able to find a suitable multi-line lambda expression. Since Python fundamentally is not an expression language, this is no great loss -- you simply write a match statement that assigns a value to the variable in each branch. Alternatively, the match could be inside a function and each block could return a value.

--
--Guido van Rossum (python.org/~guido)