TP wrote:
...
> def f():
    def f_nested():
        exec "a=2"
        print a
f()
... What is the problem? Why?

What it wants is you to provide the "in context" portion of the
exec statement.  I expect the reason it fails is that there is no
dictionary that is available as locals that encompasses the locals
of both f and f_nested, so you'll have to be explicit about what
you mean.

So, the code wants you to say something like:
    def f():
        def f_nested():
            exec "a=2" in globals(), locals()
            print a
        return f_nested
    f()

--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to