En Wed, 04 Nov 2009 02:45:23 -0300, iu2 <isra...@elbit.co.il> escribió:
On Nov 4, 3:10 am, "Gabriel Genellina" <gagsl-...@yahoo.com.ar> wrote:

txt = """
def foo(x):
   print 'x=', x

def bar(x):
   return x + x
"""

py> namespace = {}
py> exec txt in namespace
py> namespace.keys()
['__builtins__', 'foo', 'bar']
py> namespace['foo']('hello')
x= hello

What happens if both global and local dictionaries are supplied: where
are the newly created entities created? In the local dict?

The amazing thing about Python is how easy is to experiment in the interpreter.
Just see it by yourself!

--
Gabriel Genellina

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

Reply via email to