?
=?ISO-8859-1?Q?Gregory_Pi=F1ero?=
I'm curious why this code isn't working how I expect it to:
import sys
d=3
def func1(a,b,c):
print a,b,c,d
print sys.path
exec "func1(1,2,3)" in {'func1':func1}
----
returns:
1 2 3 3
[ sys.path stuff ....]
Since I'm telling exec to operate only within the context of the
dictionary I give it, why does it still see sys.path and d? I figured
it would throw a NameError.
Is there a way to call exec such that it won't have access to any more
objects than I explicitly give it?
Thanks,
Greg
import sys
d=3
def func1(a,b,c):
print a,b,c,d
print sys.path
exec "func1(1,2,3)" in {'func1':func1}
----
returns:
1 2 3 3
[ sys.path stuff ....]
Since I'm telling exec to operate only within the context of the
dictionary I give it, why does it still see sys.path and d? I figured
it would throw a NameError.
Is there a way to call exec such that it won't have access to any more
objects than I explicitly give it?
Thanks,
Greg