python - sympy.sympify() does not perform substitutions -


this works expected:

>>> sympy import * >>> (x, y, z) = symbols("x y z") >>> y = x >>> z = y >>> z x 

however sympify() not perform substitution:

>>> sympy import * >>> y = sympify('x') >>> z = sympify('y') >>> z y 

z should set x.

are there flags can pass sympify() substitute? i'm using sympy version 0.7.1.rc1 , python 2.7.3

you're misunderstanding difference between sympy symbols , python names.

>>> y = sympify('x') 

here you've created symbol x referred name y.

>>> z = sympify('y') 

now create symbol y referred name z. note symbol y , local name y have nothing each other. sympy not care have variable named y when sympify('y') -- it's not inspecting local namespace.

what want is:

>>> z = sympify(y) 

i.e. assigning z symbol pointed by y; gets expect:

>>> z x  

also note sympify call entirely redundant in case, should doing:

>>> z = y 

Popular posts from this blog