diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..b9c898e51b38f981f1a58d0a820e26cb344c543b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +__*/ +.pytest_cache diff --git a/calculator/__pycache__/Calculator.cpython-310.pyc b/calculator/__pycache__/Calculator.cpython-310.pyc deleted file mode 100644 index 24c0a7f8401cd6d66646eb6938fc36c5b8dfbf5d..0000000000000000000000000000000000000000 Binary files a/calculator/__pycache__/Calculator.cpython-310.pyc and /dev/null differ diff --git a/calculator/__pycache__/Expression.cpython-310.pyc b/calculator/__pycache__/Expression.cpython-310.pyc deleted file mode 100644 index 39cc4147cc27f4e3f9656a4e48fe56674b8f5f41..0000000000000000000000000000000000000000 Binary files a/calculator/__pycache__/Expression.cpython-310.pyc and /dev/null differ diff --git a/calculator/__pycache__/Operator.cpython-310.pyc b/calculator/__pycache__/Operator.cpython-310.pyc deleted file mode 100644 index 53418f864c433e3db52a95846f613ed4d9581a61..0000000000000000000000000000000000000000 Binary files a/calculator/__pycache__/Operator.cpython-310.pyc and /dev/null differ diff --git a/calculator/__pycache__/Operators.cpython-310.pyc b/calculator/__pycache__/Operators.cpython-310.pyc deleted file mode 100644 index 6e8f7a6a441d4e1396401e05cfb89d4727635010..0000000000000000000000000000000000000000 Binary files a/calculator/__pycache__/Operators.cpython-310.pyc and /dev/null differ diff --git a/calculator/__pycache__/calculator.cpython-310.pyc b/calculator/__pycache__/calculator.cpython-310.pyc deleted file mode 100644 index e137347312a05e1267631372d1a44dda7fc76488..0000000000000000000000000000000000000000 Binary files a/calculator/__pycache__/calculator.cpython-310.pyc and /dev/null differ diff --git a/calculator/__pycache__/server.cpython-310.pyc b/calculator/__pycache__/server.cpython-310.pyc deleted file mode 100644 index 02f6dd8e95307bfb97827355b4dc24d6df06874c..0000000000000000000000000000000000000000 Binary files a/calculator/__pycache__/server.cpython-310.pyc and /dev/null differ diff --git a/calculator/operators.py b/calculator/operators.py index c5534cf81514b6c49325df3211526004ba9a30f9..0e995ca10269611afd4276142e16e7f5ab4f6daf 100644 --- a/calculator/operators.py +++ b/calculator/operators.py @@ -1,10 +1,13 @@ """ Operator module contains the Operator class and a list of standard operators. """ + + class Operator: """ Operator class is a binary operator with a symbol, a precedence and an evaluation function. """ + def __init__(self, symbol, precedence, evaluate_function): self.symbol = symbol self.precedence = precedence @@ -16,6 +19,7 @@ class Operator: def __call__(self, left, right): return self.evaluate_function(left, right) + STANDARD_OPERATORS = { '+': Operator('+', 1, lambda a, b: a + b), '-': Operator('-', 1, lambda a, b: a - b), @@ -27,6 +31,6 @@ def test_operator(): """ Test the Operator class. """ - operator = Operator('%', 1, lambda a, b: a % b) - assert repr(operator) == '%' - assert operator(15, 4) == 3 + modulo = Operator('%', 1, lambda a, b: a % b) + assert repr(modulo) == '%' + assert modulo(15, 4) == 3