On Sat, Jun 29, 2019 at 9:41 AM Andrew Barnert <abarn...@yahoo.com> wrote:
>
> On Jun 28, 2019, at 16:10, Chris Angelico <ros...@gmail.com> wrote:
> >
> > The %s marker would accept everything up to the next literal text. So
> > if you say "%s@%s", it would read up to the at sign. The second part
> > of the proposal would be doing that, though; the "%s" handler would
> > simply accept everything and return it
>
> So, not like C scanf at all, where %s reads until white space. Also, there’s 
> nothing like your “second part”; literals are almost useless in scanf except 
> for things like binary protocols, because they’re not even looked at until 
> after the previous format specifier has already been parsed. So if, say, you 
> scan “I have 20. How many do you have?” with “I have %f. %s…”, the %f will 
> munch the “20.”, then the literal “.” will fall).
>
> Anyway, something like my unformat or your implied design might be more 
> useful, but I’m not sure that it would be. People have been trying to improve 
> on scanf for 40 years, and the only things that have caught on look nothing 
> like it (regex,  or just not having a format string at all and doing 
> something like C++ >> operator).
>

Hmm, I'm actually rather rusty on the details of C's sscanf, having
used high level languages most of the time for years. There are
[s]scanf functions in a number of languages, and I forgot to check
back what C's own semantics are.

But hey. If Python takes something that's inspired heavily by C's, and
partially by (say) Pike's, that can still be useful. And it's a fair
sight better to work with strings than character pointers.

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

Reply via email to