Hi,

I've been played with Python.Net for a week, but I can't find any sample to
use Python.Net in embedded way. I've searched many threads from the
previous emailing list, the result are not consistent, and looks like no
solution ??.

What I'm trying to do is that I want to get result (po) from C# code after
executing python command such as 'print 2+3' from python prompt.

When I executed it from nPython.exe, it prints out 5 as I expected.
However, when I run this code from embedded way. it returns 'null' always.
Would you give me some thoughts how I can get the execution result?

Basically, is this feature one of  Python.Net project intended for C#(.Net)
to be able to call python commands/scripts?

Thank you,
Spark.

using NUnit.Framework;
using Python.Runtime;

namespace CommonTest
{
    [TestFixture]
    public class PythonTests
    {
        public PythonTests()
        {

        }
        [Test]
        public void CommonPythonTests()
        {

            PythonEngine.Initialize();

            IntPtr gs = PythonEngine.AcquireLock();
            PyObject po = PythonEngine.RunString("print 2+3");
            PythonEngine.ReleaseLock(gs);

            PythonEngine.Shutdown();
        }
    }
}
_________________________________________________
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

Reply via email to