On Sat, Sep 19, 2020 at 4:46 PM Greg Ewing <greg.ew...@canterbury.ac.nz>
wrote:

> 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."
>

That's what I mean when I say that the format language isn't well suited to
parsing.

But it did find three things, or four, or .... that format specifier
doesn't have any whitespace in between the {}s. So it isn't
looking for spaces between the numbers.
 > I'm wondering whether such patterns should be disallowed on the

> basis that they're inherently ambiguous.
>

I don't know that they are ambiguous, as long as the rules are laid out
somewhere. Though confusing might be a good word :-)

-CHB

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/
>


-- 
Christopher Barker, PhD

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython
_______________________________________________
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/5CSYBX4IPBOXYPSEFHIPWQGAKFT3TBBG/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to