On 20/09/20 7:45 am, Christopher Barker wrote:
In [4]: from parse import parse
In [5]: parse("{x}{y}{z}", a_string)
Out[5]: <Result () {'x': '2', 'y': '3', 'z': '4567'}>

In [6]: parse("{x:d}{y:d}{z:d}", a_string)
Out[6]: <Result () {'x': 2345, 'y': 6, 'z': 7}>

So that's interesting -- different level of "greadiness" for strings than integers

Hmmm, that seems really unintuitive. I think a better result would
be a parse error -- "I was told to expect three things, but I only
found one."

I'm wondering whether such patterns should be disallowed on the
basis that they're inherently ambiguous.

--
Greg
_______________________________________________
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/LXUZLU3COX3IYNB5NHPSV2DUN2FGDTKL/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to