This thread caught my interest because I’ve written code that wraps fscanf More than once (And have some in production). So a few observations:
1) my primary reason for doing it was performance — reading lots of numbers into numpy arrays. I literally NEVER felt Python’s built in string manipulation facilities were inadequate. 2) C’s scanf Is well suited to pulling numbers out of text, but not a very good general purpose parser. So: while I can see a new nifty parser could be great, I’m not sure scanf is particularly good inspiration. And this clearly seems like a “put a package on PyPi, and if it really catches on, then consider adding to the stdlib” type of proposal. Finally — wasn’t there a thread recently on this list about a parser for the stdlib? -CHB On Fri, Jun 28, 2019 at 5:42 PM Greg Ewing <greg.ew...@canterbury.ac.nz> wrote: > Rhodri James wrote: > > scanf (or rather sscanf) always looks like a > > brilliant idea right up until I come to use it, at which point I almost > > always do something else that gives me better control. > > My experience is similar, but that's largely because error detection > and reporting with the C version of sscanf is pretty terrible. At > best all you can say is "there is something wrong with this line of > input". > > If the Python version could produce better diagnostics, it might > find more use. > > -- > 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/TYT6ACMNIVW4M3CKWSWB7B4SFEHPNAOE/ > 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/4NI4ECUVPBE6J4YXAZ22R64MTTSTQNHT/ Code of Conduct: http://python.org/psf/codeofconduct/