On Sat, Aug 13, 2022 at 10:23 AM Tushar Sadhwani <
tushar.sadhwani...@gmail.com> wrote:

> Stephen J. Turnbull wrote:
> > I think this is a pretty unconvincing example.  While people seem to
> > love to hate on regular expressions, it's hard to see how that beats
> > def unquote(string: str) -> str:
> >         m = re.match(r"^(?:"(.*)"|'(.*)'|(?Pvalue3))$", string)
>
> RegEx feels overkill for this. Certainly takes longer to read, understand
> and test.
>

f-strings are inherently ambiguous. You've chosen cases with unambiguous
and mutually exclusive prefixes, but that won't generally be the case.
You'd need implicit rules about greediness, which could easily lead to some
buggy code looking correct.

For what it's worth, Raymond Hettinger has some code examples that make
using regexes in match statements much easier:  see
https://www.dropbox.com/s/w1bs8ckekki9ype/PyITPatternMatchingTalk.pdf?dl=0
and https://twitter.com/i/web/status/1533369943764488192

Best wishes,
Lucas Wiman
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/SJGI7GRUWE44HO7JL4GXRDWMYRWNQKG6/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to