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

Hi,

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
    EID
    ( : +33 (0) 388 14 28 75

_________________________________________________
Python.NET mailing list - [email protected]
http://mail.python.org/mailman/listinfo/pythondotnet

Reply via email to