ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 03 May 2013 20:02:11 +0200Is there a way to update an expression with new variable values?https://ask.sagemath.org/question/10087/is-there-a-way-to-update-an-expression-with-new-variable-values/Is there a way to update an expression if the symbolic variables that it contains have been overwritten? For example,
sage: var('beta')
beta
sage: eq = x == beta
sage: beta = 1
sage: eq
x == beta
Is there a way for it to change to `x == 1`? I wrote the following function to do this, but I wanted to know if something similar existed already.
def update(expr):
return expr.subs(dict(zip(expr.variables(), map(lambda v:eval(str(v)), expr.variables()))))Eviatar BachFri, 03 May 2013 20:02:11 +0200https://ask.sagemath.org/question/10087/