1

I can evaluate an expression in NumExpr like this

numexpr.evaluate('17 == b', local_dict={'b': 17})

How can I get list of variable inside and expression like '17 == b' then I will get ['b']

Thank you.

user1501185
  • 101
  • 2
  • 2

1 Answers1

1

Maybe it can be done in a simpler way, but this works for me

import numexpr.necompiler as nec
print map(lambda x: x.value, nec.typeCompileAst(nec.expressionToAST(nec.stringToExpression(ex, {}, {}))).allOf('variable'))