On 07/07/2020 15:31, Henk-Jaap Wagenaar wrote:
On Tue, 7 Jul 2020 at 15:04, Rob Cliffe via Python-Dev <
python-dev@python.org> wrote:
      I'm not keen on special treatment of the '_' variable, and would
prefer to be able to use 'else:' after 'match'.


I used to be in this "camp", however, a (I think valid) point was raised
that "else:" is not a (full) alternative. Due to the restriction on
repeated names (e.g. Point(x, x) is illegal), if you want to "throw away"
intermediate matches, you will have to either have to come up with new
names (Point(unused_1, unused_2)) or use the "_" as currently instituted
(Point(_, _)) and "else:" does not cover that insofar as I can tell.

There are two things here, the specialness of "_" and using "else:" as the catch-all clause.

I'm not quite convinced about making "_" non-binding, mostly because of the knock-on effects in the PEP for other types of patterns. It seems to breed more special cases, and I can't help but feel that's a bad sign.

On the other hand "else:" would have exactly the effect of "case _:", so we're into arguments about there preferably being only one obvious way to do things. I'd maintain that "else:" is obvious :-)

--
Rhodri James *-* Kynesim Ltd
_______________________________________________
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/EIBEIZ7QLBO3RBH253D7ZK5WTRNKHSYD/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to