summaryrefslogtreecommitdiff
path: root/examples/htmlTableParser.py
diff options
context:
space:
mode:
authorptmcg <ptmcg@austin.rr.com>2020-04-26 10:33:12 -0500
committerptmcg <ptmcg@austin.rr.com>2020-04-26 10:33:12 -0500
commit203fa36d7ae6b79344e4bf13531b77c09f313793 (patch)
tree443459f498f38b97618344c6f707eeaa117cf670 /examples/htmlTableParser.py
parent813ba3bed433a96e02d82cad2e2940a6850d96a5 (diff)
downloadpyparsing-git-203fa36d7ae6b79344e4bf13531b77c09f313793.tar.gz
change some lambdas to explicit methods for clarity (see discussion in #207); deleted duplicated examples (commit *all* changes this time)
Diffstat (limited to 'examples/htmlTableParser.py')
-rw-r--r--examples/htmlTableParser.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/examples/htmlTableParser.py b/examples/htmlTableParser.py
index e96a913..79b61d5 100644
--- a/examples/htmlTableParser.py
+++ b/examples/htmlTableParser.py
@@ -24,7 +24,13 @@ strip_html = (pp.anyOpenTag | pp.anyCloseTag).suppress().transformString
# expression for parsing <a href="url">text</a> links, returning a (text, url) tuple
link = pp.Group(a + a.tag_body("text") + a_end.suppress())
-link.addParseAction(lambda t: (t[0].text, t[0].href))
+
+
+def extract_text_and_url(t):
+ return (t[0].text, t[0].href)
+
+
+link.addParseAction(extract_text_and_url)
# method to create table rows of header and data tags
def table_row(start_tag, end_tag):