Thanks a lot, that works for me.
--
http://mail.python.org/mailman/listinfo/python-list
Jens wrote:
> has anyone an idea why the following code does not work.
> s = """
> def a(n):
> return n*n
> def b(t):
> return a(t)
> """
> ns = {}
> exec(s, {}, ns)
Here you are providing a local namespace into which all toplevel names (a
and b) are inserted.
> eval("b(2)", ns, {})
Here
Le Mardi 16 Mai 2006 11:05, Jens a écrit :
> s = """
> def a(n):
> return n*n
>
>
> def b(t):
> return a(t)
> """
>
>
> ns = {}
> exec(s, {}, ns)
> eval("b(2)", ns, {})
you passed an empty globals dictionnary to the eval func (the local one is not
in the scope of b defintion)
try this :
exec