I\'m wondering if there exists a python module that would allow me to do something like this:
x = MagicNumber() x.value = 3 y = 2 * (x + 2) ** 2 - 8 print y
You could give sympy, a computer algebra system written in Python, give a try.
E.g.
>>> from sympy import Symbol >>> x = Symbol('x') >>> y = 2 * (x + 2) ** 2 - 8 >>> y 2*(x + 2)**2 - 8 >>> y.subs(x,3) 42 >>> y.subs(x,2) 24