New assignmens ...

Jon Ribbens jon+usenet at
Thu Oct 28 05:53:53 EDT 2021

On 2021-10-28, Paul Rubin < at nospam.invalid> wrote:
> Chris Angelico <rosuav at> writes:
>> But it all depends on the exact process being done, which is why I've
>> been asking for real examples.
> My most frequent use case for walrus is so common that I have sometimes
> implemented a special class for it:
>    if g :=, text):
>       hack(
>    elif g :=, text):
>       smack(, "foo")
>    ...
> It's way messier if you have to separate the assignment and test the old
> way.  That said, I'm still on Python 3.7 so I haven't yet gotten to use
> walrus or the new match statement (or is it expression).
> I do feel surprised that you can't use an arbitrary lvalue (to use C
> terminology) on the lhs of a walrus.  That seems downright weird to me.
> But, I haven't studied the PEP so I don't know if there was a particular
> rationale.

Well, that's what I was saying: there's no rationale - the limitation
is not even mentioned, let alone explained.

More information about the Python-list mailing list