From fc67ec2ac8acef2f5f08ce4bb78a8414bb5a20aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Mon, 11 Feb 2019 21:39:36 +0100 Subject: [PATCH] Eval --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4f149f5..a35ace7 100644 --- a/README.md +++ b/README.md @@ -1405,7 +1405,7 @@ import ast from ast import Num, BinOp, UnaryOp import operator as op -legal_operators = {ast.Add: op.add, +LEGAL_OPERATORS = {ast.Add: op.add, ast.Sub: op.sub, ast.Mult: op.mul, ast.Div: op.truediv, @@ -1424,9 +1424,9 @@ def eval_node(node): if node_type not in [BinOp, UnaryOp]: raise TypeError(node) operator_type = type(node.op) - if operator_type not in legal_operators: + if operator_type not in LEGAL_OPERATORS: raise TypeError(f'Illegal operator {node.op}') - operator = legal_operators[operator_type] + operator = LEGAL_OPERATORS[operator_type] if node_type == BinOp: left, right = eval_node(node.left), eval_node(node.right) return operator(left, right)