generic object - moving toward PEP

Steven Bethard steven.bethard at gmail.com
Sun Nov 21 17:47:34 EST 2004


Paul McGuire wrote:
> 
> This sounds *very* much like the ParseResults class that I implemented in
> pyparsing.  For a given set of results from a parsing operation, one can
> access them:
> - as a list (tokens[0], tokens[1], ...)
> - as a dict (tokens["name"], tokens["phoneNum"], ...)
> - as attributes (tokens.name, tokens.phoneNum, ...)
[snip]
> As an afterthought, I then added an XML output format for this class, so
> that tokens.asXML("PERSONAL_DATA") would generate:
> <PERSONAL_DATA>
>   <name>John Doe</name>
>   <phoneNum>555-1212</phoneNum>
> </PERSONAL_DATA>

Yeah, the last time I really wanted this, it was because I had an XML 
document and wanted a somewhat more convenient access pattern than SAX 
or DOM...  I'll definitely check out your ParseResults class before I 
try to submit a patch.  Thanks!

Steve



More information about the Python-list mailing list