I\'m trying to use [SymPy][1] to substitute multiple terms in an expression at the same time. I tried the [subs function][2] with a dictionary as parameter, but found out that i
Example for @~unutbu's answer:
>>> import ordereddict # collections.OrderedDict in Python 2.7+ >>> from sympy import * >>> x,y,z = symbols('xyz') >>> x.subs(ordereddict.OrderedDict([(x,y),(y,z)])) y >>> x.subs(ordereddict.OrderedDict([(y,z),(x,y)])) z