There was a discussion about this a couple months ago but instead of adding a 
new keyword the idea was that the walrus operator could be upgraded from simply 
being a binding operator to matching patterns supported by the match statement.

if ["example", *files] := variable:
    print(files)

If the pattern doesn't match the expression would evaluate to None instead of 
the right hand side value. The current syntax would still work the same as it 
would be interpreted as an unconditional name binding pattern.

foo = [1, 2, 3]
assert ([] := foo) is None
assert ([a, b, c] := foo) is foo
assert (bar := foo) is foo  # No special case needed for the current behavior
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/67C6OWL5YOFYKXJGY6XI34JKJC6WBUGT/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to