From 203fa36d7ae6b79344e4bf13531b77c09f313793 Mon Sep 17 00:00:00 2001 From: ptmcg Date: Sun, 26 Apr 2020 10:33:12 -0500 Subject: change some lambdas to explicit methods for clarity (see discussion in #207); deleted duplicated examples (commit *all* changes this time) --- examples/htmlTableParser.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'examples/htmlTableParser.py') 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 text 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): -- cgit v1.2.1