[Python.NET] How to run a .py file from C#

LIVERNAIS Sylvie livernsy at e-i.com
Thu Jun 1 17:08:21 CEST 2006


I'm a newbie in C# and python and try to run a .py file from a C# program.

I tried the same thing from a C++ program using PyRun_SimpleFile and in the console, I could see the python execution (the print from python).
Using Python.Runtime.dll from Python.NET, I saw that such a fonction is not available, and should use PythonEngine.ImportModule and PythonEngine.RunString or PythonEngine.RunSimpleString. The thing is that it only works for a command written over one line, but if I have a "def" (which is written over several lines), the RunString doesn't work any more... So how can I run the whole file, and not only line by line ?

By the way, what does exactly the ImportModule function ? Maybe the .py file is already executed but I can't see it ? Is there a way to get the output and display it in the console ?

Thanks for you answer

	__ Sylvie LIVERNAIS ___________
	Applications Cartes à Puce
	* : +33 (0) 388 14 28 75

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/pythondotnet/attachments/20060601/28274cce/attachment.html 

More information about the PythonDotNet mailing list