[IronPython] Need a Good Embedded Example

Joshua J. Pearce joshua.pearce at gmail.com
Tue Oct 16 23:08:04 CEST 2007


I have been looking for a good example of embedding IronPython in a c#
application. I am under the impression that there have been some major
changes in the way this is done from version 1.1 to 2.0.

This is what I found at the Python Cookbook site:

namespace IronPythonScriptHost
{
    class Program
    {
        static void Main(string[] args)
        {
            string code = "print \"Hello \" + Name";
            Script.SetVariable("Name", "Me");
            Script.Execute("py", code);
        }
    }
}

That's nice, but doesn't really help me to know how to get variable output
from the script back to my c# code. I also need to know how to call scripts
with multiple statements and whether all variables need to be set on the
script object, or can their declaration just be part of the script code.

Is there a good and simple example anywhere that shows how to host the
IronPython engine in a c# app and let users manipulate your program objects
via ipy scripts?

Thanks!

-- 
Joshua Pearce
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20071016/f90c77de/attachment.html>


More information about the Ironpython-users mailing list