This "works", maybe this is not what you really need
>>> from sympy import *
>>> x = Symbol('2')
>>> x
2
>>> x**3 * x**7
2**10
>>> z = x**3 * x**7
>>> z
2**10
>>> str(z)
'2**10'
>>> eval(str(z))
1024
note added (using @if clause ....)
>>> two = Symbol('2', positive=True, integer=True)
>>> z = two**3 * two**7
>>> z
2**10
>>> z.subs(two, 2)
1024
addition also 'works'
>>> two**3 + two**7
2**7 + 2**3
>>> ((two**3 + two**7)).subs(two,two)
2**7 + 2**3
>>> ((two**3 + two**7)).subs(two, 2)
136
source
share