[IronPython] Sharing state between embedded PythonEngines

Michael Foord fuzzyman at voidspace.org.uk
Wed Apr 11 21:39:32 CEST 2007

Chris Stoy wrote:
> Hi all,
> I’m working on embedding IronPython in a C# application and would like 
> to have a single, global module where I expose my objects and run 
> scripts, and have multiple views into that state.
That is certainly possible - but I'm not sure how easy it will be to 
have multiple *consoles*.

Creating a custom control which receives input and displays the result 
in a window. (Sharing a single context behind the scenes...)

Is using consoles as your view, central to your application ?


> For example, I want to have one (or more) IronPython console views 
> that provide an interactive prompt that the user can type in and 
> execute code. If I enter a function/variable in one of the consoles, 
> then it is also available in the others. (ie, I enter “x=1” in console 
> A and in console B I can say “print x” and see “1” output.) I also 
> want to execute much larger, non-interactive scripts that a user can 
> write and, again, this state is shared across all my IronPython views.
> So, am I just thinking about this wrong? How are people embedding 
> IronPython in their apps? It seems strange (and inefficient) to have 
> to create a new PythonEngine and add all the references and expose 
> globals every time I want to execute script. Is there a way to share 
> some of this state? Can this be done using EngineModules?
> Any thoughts would be appreciated.
> Thanks.
> Chris.
> ------------------------------------------------------------------------
> _______________________________________________
> users mailing list
> users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

More information about the Ironpython-users mailing list