runScript

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

runScript

Alan Macdonald-3

I am trying to put together a basic proof of concept for running some python on the CPython interpreter from a C# host application.  I have successfully invoked the RunSimpleString method on the PythonEngine class as follows:

 PythonEngine.Initialize();
IntPtr lockPtr = PythonEngine.AcquireLock();
var result = PythonEngine.RunSimpleString(@"print ""hello""");
PythonEngine.ReleaseLock(lockPtr);
PythonEngine.Shutdown();

This worked as expected and output hello to the command prompt.


I then wanted to make sure I could get a simple example working with RunString so tried the following

PythonEngine.Initialize();
 IntPtr lockPtr = PythonEngine.AcquireLock();
 var result = PythonEngine.RunString(@"print ""hello""
         print ""test""
 ");
           
PythonEngine.ReleaseLock(lockPtr);
PythonEngine.Shutdown();

This just appears to do nothing and the returned result object is null.  Am I getting the complete wrong end of the stick with how to use RunString?

 

My System is:

 

Windows 7 x64

Python 2.6.6 (64 bit)

The Python .net I downloaded was pythonnet-2.0-alpha2-136-py26.zip

My Visual Studio project is set to .Net 3.5



Thanks for your time,

 

Alan


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