Re: how to compile this code

2016-11-01 Thread meInvent bbird
>>> class ChangeAddToMultiply(ast.NodeTransformer, ast2.NodeTransformer): ... """Wraps all integers in a call to Integer()""" ... def visit_BinOp(self, node): ... print(dir(node)) ... print(dir(node.left)) ... if isinstance(node.op, ast.Add): ... ast.Call

Re: how to compile this code

2016-11-01 Thread Yann Kaiser
You want to replace the `Add` ast with a `Call` ast rather than just calling your function. Something like: if isinstance(node.op, ast.Add): return ast.Call(some_ast_expression_that_will_evaluate_to_op, [node.left, node.right], []) You'll have to replace some_ast_expression_... to so

how to compile this code

2016-10-31 Thread meInvent bbird
would like to change Add operator to custom function op2 in solve function and then this solve([x*y - 1, x + 2], x, y) during solve, the parameters also change Add to custom function op2 import ast from __future__ import division from sympy import * x, y, z, t = symbols('x y z t') k, m, n = symbo