[Python.NET] runScript
Alan Macdonald
alan.macdonald at hrhgeology.com
Mon Nov 7 09:55:00 CET 2011
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pythondotnet/attachments/20111107/ae7f961c/attachment.html>
More information about the PythonDotNet
mailing list