From 8e5e388482885fdc95b85b12aecdb109a9d137ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Fri, 28 Dec 2018 18:18:26 +0100 Subject: [PATCH] Eval --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 9e0e168..7a8b05a 100644 --- a/README.md +++ b/README.md @@ -1093,17 +1093,17 @@ Eval ### Detailed ```python -from ast import parse, Num, BinOp, UnaryOp, \ - Add, Sub, Mult, Div, Pow, BitXor, USub +import ast +from ast import parse, Num, BinOp, UnaryOp import operator as op -operators = {Add: op.add, - Sub: op.sub, - Mult: op.mul, - Div: op.truediv, - Pow: op.pow, - BitXor: op.xor, - USub: op.neg} +operators = {ast.Add: op.add, + ast.Sub: op.sub, + ast.Mult: op.mul, + ast.Div: op.truediv, + ast.Pow: op.pow, + ast.BitXor: op.xor, + ast.USub: op.neg} def evaluate(expression): root = parse(expression, mode='eval')