On Wed, Apr 20, 2011 at 12:03 PM, Chris Angelico <ros...@gmail.com> wrote: > On Thu, Apr 21, 2011 at 12:44 AM, Ian Kelly <ian.g.ke...@gmail.com> wrote: >> So, the question for the OP: Is this file being run with execfile? >> > > Not execfile per se; the code is fetched from the database and then > executed with: > > PyObject *v=PyRun_StringFlags(code,Py_file_input,py_globals,locals,0); > > Is Py_file_input the problem?
Not specifically. The problem is that you're execing the code, and the locals and globals are two different namespaces, as Peter suggested. Since the locals namespace is not associated with a function, the compiler evidently doesn't generate closures for it, and thus the lambda (which has its own locals namespace) can't see it. That's my take, anyway. Somebody else may have better insight than me. Cheers, Ian -- http://mail.python.org/mailman/listinfo/python-list