In a type expression
import sympy a = sympy.Symbol('a') b = sympy.Symbol('b') x = a + 2*b
I would like to exchange a and b for a choice of b + 2*a . I tried
y = x.subs([(a, b), (b, a)]) y = x.subs({a: b, b: a})
but does not work; the result of 3*a in both cases as b for some reason replaced first.
Any clues?
source share