summaryrefslogtreecommitdiff
path: root/examples/excelExpr.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/excelExpr.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/excelExpr.py')
-rw-r--r--examples/excelExpr.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/examples/excelExpr.py b/examples/excelExpr.py
index cea2eea..5c87d93 100644
--- a/examples/excelExpr.py
+++ b/examples/excelExpr.py
@@ -59,13 +59,15 @@ ifFunc = (
+ RPAR
)
-statFunc = lambda name: Group(
- CaselessKeyword(name) + Group(LPAR + delimitedList(expr) + RPAR)
-)
-sumFunc = statFunc("sum")
-minFunc = statFunc("min")
-maxFunc = statFunc("max")
-aveFunc = statFunc("ave")
+
+def stat_function(name):
+ return Group(CaselessKeyword(name) + Group(LPAR + delimitedList(expr) + RPAR))
+
+
+sumFunc = stat_function("sum")
+minFunc = stat_function("min")
+maxFunc = stat_function("max")
+aveFunc = stat_function("ave")
funcCall = ifFunc | sumFunc | minFunc | maxFunc | aveFunc
multOp = oneOf("* /")
@@ -79,14 +81,14 @@ arithExpr = infixNotation(
textOperand = dblQuotedString | cellRef
textExpr = infixNotation(textOperand, [("&", 2, opAssoc.LEFT),])
-expr << (arithExpr | textExpr)
+expr <<= (arithExpr | textExpr)
(EQ + expr).runTests(
"""\
=3*A7+5
=3*Sheet1!$A$7+5
- =3*'Sheet 1'!$A$7+5"
+ =3*'Sheet 1'!$A$7+5
=3*'O''Reilly''s sheet'!$A$7+5
=if(Sum(A1:A25)>42,Min(B1:B25),if(Sum(C1:C25)>3.14, (Min(C1:C25)+3)*18,Max(B1:B25)))
=sum(a1:a25,10,min(b1,c2,d3))