[IronPython] How to get a ScriptEngine from within a running IronPython script?

Dan Eloff dan.eloff at gmail.com
Wed Jul 16 23:00:28 CEST 2008


Dino showed me Application.Current.Environment.GetEngine('py'), which
has been my constant companion is Silverlight, but how can I get the
(a?) ScriptEngine in a regular IronPython script?

I suppose I could create one:

from Microsoft.Scripting.Hosting import ScriptRuntime
runtime = ScriptRuntime.Create()
Engine = runtime.GetEngine("py")

And I'm not sure I would ever notice the difference for what I use it
for (what kind of general differences might there be?), but it'd be
nice to know if you can get a reference to the existing ScriptEngine.
I have no idea how many resources a ScriptEngine consumes, although I
would guess it's trivial.

Thanks,
-Dan



More information about the Ironpython-users mailing list