you can use the exec method.
exec
a = 12 exec('b='+dir()[-1]) print(b) >>> 12
the exec method executes the string inputs.
2.1m questions
2.1m answers
60 comments
57.0k users