On Aug 12, 5:52 pm, "Edward K. Ream" <[email protected]> wrote:
> The problem is that exec adds the definitions in the *local* context,
> and that context is the context of findTestScript, not the caller.
> This problem should be solvable...
The following code discovers what symbols have been added by the exec:
_addTestScript_s = g.getScript(c,p)
_addTestScript_d = None # To put it in locals
_addTestScript_d = locals().copy()
exec(_addTestScript_s)
added = [z for z in locals() if not z in _addTestScript_d]
print(added)
I use the strange symbols to ensure the names here won't clash with
the names in the script being executed.
After the exec, the 'added' array contains 'Hello' as expected and
locals().get('Hello') yields <class 'Hello'>.
So the only task left is to add the following list to the locals of
the *caller*:
[locals.get(z) for z in added]
Edward
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/leo-editor?hl=en.