demo_ref_exec.py:
x = 'name = "John"\nprint(name)' exec(x)
➜ begtut>python demo_exec.py
John