Description
PLY and PyParsing
Presented by Andrew Dalke
Got a text parsing problem? In most cases using string manipulation and regular expressions will solve it for you. But when the input is complex, try reaching for a parsing system to help out.
The two most popular in Python are PLY and PyParsing. PLY follows the lex/yacc tradition with a domain specific language to describe the tokens and grammar. It was built with both error diagnostics and performance in mind. PyParsing is a recursive descent parser which expresses the format as a Python data structure. It make no distinction between lexer and grammar and has a uniform callback system which makes certain types of data extraction very easy.
In my talk I'll show the basics of how to use both systems for several different format parsing tasks, of different complexity. This will let you see how to use the parsers and understand more of the tradeoffs between complexity, readability, error handling, and performance.