Embedding Python in C#...

Brian Lloyd brian at zope.com
Fri Mar 1 13:54:30 EST 2002


> >has this been done?
> 
> Not that I know of.
> 
> >is it even possible?
> 
> I am pretty sure, yes.

(Sorry I'm a little behind on this...)

Yep - and it's pretty easy (though I'm not totally done yet) :)
It looks something like:

PythonInterpreter python = new PythonInterpreter();
PyModule sys = python.ImportModule("sys");
PyList list = (PyList)sys.GetAttr("path");
Console.WriteLine("Sys.path is: {0}", list.ToString());
Console.WriteLine("Item 0 is: {0}", list[0].ToString());


> >if it has where can i obtain information on doing so?

If you're interested in playing with it in-progress, let 
me know. 


Brian Lloyd        brian at zope.com
Software Engineer  540.361.1716       
Zope Corporation   http://www.zope.com





More information about the Python-list mailing list