On Tue, Jun 23, 2020 at 9:12 AM Guido van Rossum <gu...@python.org> wrote:
> I'm happy to present a new PEP for the python-dev community to review. > This is joint work with Brandt Bucher, Tobias Kohn, Ivan Levkivskyi and > Talin. > ... > I'll mostly let the PEP speak for itself: > - Published: https://www.python.org/dev/peps/pep-0622/ (*) > - Source: https://github.com/python/peps/blob/master/pep-0622.rst > I have an exploratory question. In this section: The alternatives may bind variables, as long as each alternative binds the > same set of variables (excluding _). For example: > match something: > ... > case Foo(arg=x) | Bar(arg=x): # Valid, both arms bind 'x' > ... > ... Tweaking the above example slightly, would there be a way to modify the following so that, if the second alternative matched, then 'x' would have the value, say, None assigned to it? match something: > ... > case Foo(arg=x) | Bar() (syntax assigning, say, None to x?) > ... > ... That would let Bar be handled by the Foo case even if Bar doesn't take an argument. I'm not sure if this would ever be needed, but it's something I was wondering. I didn't see this covered but could have missed it. --Chris >
_______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/47B3J7CMO3O7AORZ6ZGT4SMOEJILPNZT/ Code of Conduct: http://python.org/psf/codeofconduct/