diff options
author | Jon Dufresne <jon.dufresne@gmail.com> | 2019-10-24 20:11:14 -0700 |
---|---|---|
committer | Paul McGuire <ptmcg@users.noreply.github.com> | 2019-10-24 22:11:14 -0500 |
commit | f73e2571fb643a2afdde365eeee0fe0f3f4f5300 (patch) | |
tree | f9015586cee7efc5e60eee78a8ebcbaa4e9e953d /examples/eval_arith.py | |
parent | 696808023f10207461d7b22dc1d02cbed44e2bfa (diff) | |
download | pyparsing-git-f73e2571fb643a2afdde365eeee0fe0f3f4f5300.tar.gz |
Use pyupgrade to upgrade the code to use Python3 conventions (#138)
The pyupgrade project is available at
https://github.com/asottile/pyupgrade and can be installed through pip.
The pyupgrade tool automatically upgrades syntax for newer versions of
the language. As pyparsing is now Python 3 only, can apply some cleanups
and simplifications. Ran the tool using the following command:
$ find . -name \*.py -exec pyupgrade --py3-plus {} \;
For now, pyparsing.py was skipped while it is refactored to a package.
Diffstat (limited to 'examples/eval_arith.py')
-rw-r--r-- | examples/eval_arith.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/examples/eval_arith.py b/examples/eval_arith.py index 0896c01..8f3e996 100644 --- a/examples/eval_arith.py +++ b/examples/eval_arith.py @@ -11,7 +11,7 @@ from pyparsing import Word, nums, alphas, Combine, oneOf, \ opAssoc, infixNotation, Literal -class EvalConstant(object): +class EvalConstant: "Class to evaluate a parsed constant or variable" vars_ = {} def __init__(self, tokens): @@ -22,7 +22,7 @@ class EvalConstant(object): else: return float(self.value) -class EvalSignOp(object): +class EvalSignOp: "Class to evaluate expressions with a leading + or - sign" def __init__(self, tokens): self.sign, self.value = tokens[0] @@ -39,7 +39,7 @@ def operatorOperands(tokenlist): except StopIteration: break -class EvalPowerOp(object): +class EvalPowerOp: "Class to evaluate multiplication and division expressions" def __init__(self, tokens): self.value = tokens[0] @@ -49,7 +49,7 @@ class EvalPowerOp(object): res = val.eval()**res return res -class EvalMultOp(object): +class EvalMultOp: "Class to evaluate multiplication and division expressions" def __init__(self, tokens): self.value = tokens[0] @@ -62,7 +62,7 @@ class EvalMultOp(object): prod /= val.eval() return prod -class EvalAddOp(object): +class EvalAddOp: "Class to evaluate addition and subtraction expressions" def __init__(self, tokens): self.value = tokens[0] @@ -75,7 +75,7 @@ class EvalAddOp(object): sum -= val.eval() return sum -class EvalComparisonOp(object): +class EvalComparisonOp: "Class to evaluate comparison expressions" opMap = { "<" : lambda a,b : a < b, |