Open GoogleCodeExporter opened 9 years ago
Salut Nicolas
Could you give an example where exec() doesn't work ?
On the Brython site console, if you enter :
x = "for i in range(10):\n print(i)"
exec(x)
you get the expected result
Original comment by pierre.q...@gmail.com
on 21 Feb 2013 at 9:20
Well... I am trying to reproduce the problem in a simple test case but I can't.
However, there is a big difference with Python3 implementation : With Python3,
locals modified by exec() are not visible from the caller. You have to pass
your own dict :
def req_str(req):
loc = {}
exec(req, globals(), loc)
return loc["output"]
Original comment by d...@famillepinault.fr
on 21 Feb 2013 at 9:51
req_str is called like this for it to work correctly :
o = req_str("output = 'test'")
print(o)
Original comment by d...@famillepinault.fr
on 22 Feb 2013 at 7:53
Original issue reported on code.google.com by
d...@famillepinault.fr
on 20 Feb 2013 at 9:16