On 2/3/2010 3:30 AM, Simon zack wrote:
hi,
I'm not sure how I can use exec within a function correctly
here is the code i'm using:

def a():
     exec('b=1')
     print(b)

a()

this will raise an error, but I would like to see it outputting 1

Always **copy and paste** **complete error tracebacks** when asking a question like this. (The only exception would be if it is v e r y long, as with hitting the recursion depth limit of 1000.)

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to