[Python-Dev] Re: Some pattern annoyance

2023年8月02日 04:29:32 -0700

> On 2 Aug 2023, at 12:03, Christian Tismer-Sperling <[email protected]> 
> wrote:
> 
> Hi folks,
> 
> I just used Structural Pattern Matching quite intensively and I'm
> pretty amazed of the new possibilities.
> 
> But see this code, trying to implement Mark Pilgrim's regex
> algorithm for roman literals with SPM:
> 
> With constants, I can write
> 
> match seq:
> case "M", "M", "M", "M", *r:
> return 4 * 1000, r
> 
> But if I want to use abbreviations by assignment, this is no longer
> possible, and I have to write something weird like:
> 
> M = "M"
> match seq:
> case a, b, c, d, *r if M == a == b == c == d:
> return 4 * 1000, r
> 
> So what is missing seems to be a notion of const-ness, which
> could be dynamically deduced. Am I missing something?
Try asking for help at https://discuss.python.org/
This list is not for help or ideas, also its basically dead.
Barry
> 
> -- 
> Christian Tismer-Sperling :^) [email protected]
> Software Consulting : http://www.stackless.com/
> Strandstraße 37 : https://github.com/PySide
> 24217 Schönberg : GPG key -> 0xFB7BEE0E
> phone +49 173 24 18 776 fax +49 (30) 700143-0023
> _______________________________________________
> 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/5MKBWCSVYZKR3S7OVY6KBF6FE7WYB5LC/
> Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________
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/IN472AS2RMBFSLNUKCSOGWKTD3EN2ZX4/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to