czw., 12 lis 2020 o 19:41 Paul Sokolovsky <pmis...@gmail.com> napisał(a): > > Hello, > > On Thu, 12 Nov 2020 09:55:10 -0800 > Guido van Rossum <gu...@python.org> wrote: > > > The position of PEP 622/634/535/636 authors is clear: we see this as a > > necessary feature to support using enums (e.g. Color.RED) or constants > > defined in other modules (e.g. re.I) when simple switch functionality > > is being migrated from literals (e.g. case 404) to named constants > > (e.g. case HTTPStatus.NOT_FOUND). Bothering users with the > > technicality of needing to use '==' here is a big usability hit. > > As was pointed out many times on the mailing list, there's a very > obvious way around needing to use '==' there. It's explicitly marking > capturing terms in case's: > > match foo: > case ("foo", >val1): > ... > case ("bar", >val2): > ...
I agree with that, though I would prefer using other symbol than > (? or $), one of reasons would by it would look better as "match all" target, other one that in future. it would allow extending syntax for simple guards like ?x < 100. -- 闇に隠れた黒い力 弱い心を操る _______________________________________________ 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/PF5NNAXG2RKR3WFBEQ65JHZVI73Z7CYB/ Code of Conduct: http://python.org/psf/codeofconduct/