def eval_node(node):
 if isinstance(node, ast.Num):
  return node.n
 elif isinstance(node, ast.operator):
  return OPERATORS[type(node)]
 elif isinstance(node, ast.BinOp):
  return eval_node(node.op)(eval_node(node.left), eval_node(node.right))
 else:
  raise ValueError(node)

def eval_node ( node ) : if isinstance ( node , ast . Num ) : return node . n elif isinstance ( node , ast . operator ) : return OPERATORS [ type ( node ) ] elif isinstance ( node , ast . BinOp ) : return eval_node ( node . op ) ( eval_node ( node . left ) , eval_node ( node . right ) ) else : raise ValueError ( node )
evaluates single ast node .