[Ironpython-users] Simulating Python's scoping at the DLR level

Doug Blank doug.blank at gmail.com
Tue Dec 20 09:15:20 CET 2011


What would be a good way to simulate Python's scoping rules at the DLR level?

For example, if I were running two DLR-based scripts, I can just use
the same ScriptScope for both to have shared globals.

But how would you replicate Python's exact idea of a local environment
in each, while falling back to a shared, global one, in DLR-based
code?

I guess I'm looking for something like:

   Execute("x = y + z", local1, globals);
   Execute("x = y + z", local2, globals);
where local1, local2, and globals are dictionaries, and "x" would end
up being added to the local dictionaries, and "y" and "z" would be
looked for first in local1 or 2, then a shared globals.

Any suggestions?

Thanks!

-Doug


More information about the Ironpython-users mailing list