ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> python-list
python-list
Re: scanf style parsing
by Steve Clift other posts by this author
Sep 28 2001 3:54AM messages near this date
Re: scanf style parsing | Re: scanf style parsing
A decade or two ago I wrote a sscanf module for just these reasons. It
used to be buried in the depths of python.org, but I haven't checked on
its whereabouts lately. I mostly use it for converting tabular stuff
produced by other programs - the standard approaches (re, split etc) can
be relatively gruesome for this sort of thing. The version currently at
large has a minor bug or two. If anyone wants an updated version, drop
me a line.

I wasn't aware of the Python-dev suggestion, but it invoked a strong
feeling of "I think I've been here before". When I first cooked this
thing up, I suggested to Guido that 'string' / 'format' ->  [list] was an
obvious move. He wasn't impressed with the notion, but I don't recall
why.

-Steve

Bruce Dawson wrote:
>  
>  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.
-- 
http://mail.python.org/mailman/listinfo/python-list
Thread:
Bruce Dawson
Skip Montanaro
George Demmy
Hans-Peter Jansen
Quinn Dunkan
Tim Hammerquist
Ralph Corderoy
Toby Dickenson
Duncan Booth
Aahz Maruch
Aahz Maruch
Aahz Maruch
Stefan Schwarzer
Grant Edwards
Fredrik Lundh

Malcolm Tredinnick
Ralph Corderoy
Tim Hammerquist
Stefan Schwarzer
Greg Ewing
Skip Montanaro
Boyd Roberts
Steve Clift
Bruce Dawson
Tim Hammerquist
Tim Hammerquist
Tim Hammerquist
Skip Montanaro
Andrew Dalke
Fredrik Lundh
Oleg Broytmann
Andrei Kulakov
Duncan Booth
Chris Barker
Tim Hammerquist
Skip Montanaro
Jon Nicoll
Oleg Broytmann
Bruce Dawson
Skip Montanaro
Andrei Kulakov
Richard Jones
Skip Montanaro
Andrew Dalke

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved