basically, I have some code defined to be executed in a restricted namespace:
code = '''
def func():
print 'success'
'''
NS = {}
NS.update(__builtins__)
exec code in NS
try:
f = NS['func']
print f # should print a function object
f()
except KeyError: print 'failure'
as you can guess... it fails
how can I make it succeed??
really what I'm trying to do is collect the function definition for intellisense operations in my IDE.
(basically I'm doing what other python IDEs that boast about intellisense (except VS2010 with Python Tools) fail to do)