Hi,<div><br></div><div>I wrote a code PythonWrapper and SimplePythonTest which uses PythonWrapper.</div><div><br></div><div><br></div><div>using SimplePython;</div><div><br></div><div><div>namespace SimplePythonTest</div><div>
{</div><div>    /// <summary></div><div>    /// Python Wrapper Tests</div><div>    /// </summary></div><div>    [TestFixture]</div><div>    public class PythonTests</div><div>    {</div><div>        PythonWrapper py;</div>
<div>        /// <summary></div><div>        /// PythonTests Constructor</div><div>        /// </summary></div><div>        public PythonTests()</div><div>        {</div><div>            py = new PythonWrapper();</div>
<div><br></div><div>            py.Init();</div><div><br></div><div>            PyObject po;</div><div>            po = py.LoadModule("os");</div><div>            po = py.LoadModule("sys");</div><div>            po = py.LoadModule("psutil");</div>
<div>        }</div><div><br></div><div>        /// <summary></div><div>        /// Python Simple Test</div><div>        /// </summary></div><div>        [Test]</div><div>        public void CommonPythonTests()</div>
<div>        {</div><div>            PyObject po = py.Execute("os.getcwd()");</div><div>            Trace.WriteLine(po.Repr());</div><div><br></div><div>            py.Close();</div><div>        }</div><div>    }</div>
<div>}</div></div><div><br></div><div><br></div><div><div>namespace SimplePython</div><div>{</div><div>    /// <summary></div><div>    /// Python Wrapper via XMLRPC/Python 2.7.3/.Net for Python.</div><div>    /// </summary></div>
<div>    public class PythonWrapper</div><div>    {</div><div>        /// <summary></div><div>        /// Inter Lock</div><div>        /// </summary></div><div>        private IntPtr gs;</div><div><br></div><div>
        /// <summary></div><div>        /// Constructor</div><div>        /// </summary></div><div>        public PythonWrapper()</div><div>        {</div><div>        }</div><div><br></div><div>        /// <summary></div>
<div>        /// Initialize PythonEngine</div><div>        /// </summary></div><div>        public void Init()</div><div>        {</div><div>            PythonEngine.Initialize();</div><div>            gs = PythonEngine.AcquireLock();</div>
<div><br></div><div>        }</div><div><br></div><div>        /// <summary></div><div>        /// Load Module</div><div>        /// </summary></div><div>        /// <param name="strModule">Module Name</param></div>
<div>        /// <returns></returns></div><div>        public PyObject LoadModule(string strModule)</div><div>        {</div><div>            return PythonEngine.ImportModule(strModule);</div><div>        }</div>
<div><br></div><div>        /// <summary></div><div>        /// Execute Python Command</div><div>        /// </summary></div><div>        /// <param name="strCommand">Python Command</param></div>
<div>        /// <returns></returns></div><div>        public PyObject Execute(string strCommand)</div><div>        {</div><div>            PyObject po = PythonEngine.RunString(strCommand);</div><div>            </div>
<div>            return po;</div><div>        }</div><div><br></div><div>        public void Close()</div><div>        {</div><div>            PythonEngine.ReleaseLock(gs);</div><div>            PythonEngine.Shutdown();</div>
<div>        }</div><div>    }</div><div>}</div></div><div><br></div><div>When testing (CommonPythonTests),  it initializes and loads modules, but PythonEngine.RunString() doesn't seem to work properly. Is any something wrong in my code which gets os.getcwd()? Furthermore, I can't find the difference between PythonEngine.RunString() and PythonEngine.RunSimpleString().</div>
<div><br></div><div>Thank you,</div><div>Spark.</div>