[IronPython] how to access a SysModule variable from a script

ecullen ecullen at fibertel.com.ar
Thu Aug 26 22:20:04 CEST 2010

hi all
    I have a program in c# which hosts IronPython scripts. I set a variable in SysModule using this:

Dictionary<String, Object> options = new Dictionary<String, Object>();
options.Add("ShowClrExceptions", true);
options.Add("ExceptionDetail", true);
options.Add("Debug", true);
ScriptEngine _scriptEngine = Python.CreateEngine(options);
ScriptScope _scriptScope = _scriptEngine.CreateScope();

ScriptScope sysScope = scriptEngine.GetSysModule();
sysScope.SetVariable("mySysVar", true);

_scriptEngine.ExecuteFile("something.py", _scriptScope);

Now, I want to read variable "mySysVar" from inside the script "something.py". How can I do that? 

I tried
import sys

if sys.mySysVar:

and also 


but they don't work.

Thanks in advance

Ernesto Cullen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20100826/326fb89a/attachment.html>

More information about the Ironpython-users mailing list