Parsing#
Three weight classes.
Built-ins (
str.split,str.partition,json,csv,configparser,tomllib,urllib.parse). First choice when the format is one of these.Regex (
re,regex). When the format is line-oriented and the patterns are stable.Real parser (
pyparsing,parsy,lark,ANTLR4Python target). When the grammar is real and the operator needs an AST.
Don’t parse XML or HTML with regex. Use lxml,
html.parser, or beautifulsoup4.