scanf style parsing

Bruce Dawson comments at cygnus-software.com
Wed Sep 26 01:42:45 EDT 2001


I love programming in Python, but there are some things I have not found
the easy way to do. I understand that Python is supposed to be good at
text parsing, but I am having trouble with this simple task. Given this
text (the output from VisualC++) I want to find out how many errors and
warnings there were:

smtpmail.exe - 0 error(s), 0 warning(s)

In C/C++ that would be something like:
sscanf(buffer, "smtpmail.exe - %d error(s), %d warning(s)", &errors,
&warnings);

It's not that I think the sscanf syntax is particularly elegant, but it
sure is compact! I saw the discussion about adding scanf to Python

http://mail.python.org/pipermail/python-dev/2001-April/014027.html

but I need to know what people do right now when faced with this task.

Let me know. E-mail answer as well would be nice, since this newsgroup
is rather high-traffic.





More information about the Python-list mailing list