[Python-Dev] Re: PEP 622: Structural Pattern Matching -- followup

2020年7月07日 20:01:39 -0700

Why not use '=' to distinguish binding from equality testing:
case Point(x, =y): # matches a Point() with 2nd parameter equal to y; if it does, binds to x. This would allow a future (or present!) extension to other relative operators:
  case Point(x, >y):
(although the syntax doesn't AFAICS naturally extend to specifying a range, i.e. an upper and lower bound, which might be a desirable thing to do.
Perhaps someone can think of a way of doing it).
Whether
  case =42:
  case 42:
would both be allowed would be one issue to be decided.
Rob Cliffe
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/MENII4GJ66JHWBKNTNJSJOYCMSMLSIRO/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to