Is it intended that closures created in exec statement/function cannot see
locals if the exec was provided a locals dictionary?

This code gives an error ("foo" is not found during lambda execution):

    exec("def foo(x): return x\n\n(lambda x:foo(x))(0)", globals(), {})

while executes normally with

    exec("def foo(x): return x\n\n(lambda x:foo(x))(0)")

Is this the expected behavior? If so where is it documented?

Andrea
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to