[Python.NET] Error in calling Python class method from C#
techi eth
techieth at gmail.com
Wed Apr 25 08:38:01 EDT 2018
Hi,
I am facing issue while calling python class function in C# programme. Can
anyone give me hint what is wrong in below programme.While running I am
getting error in invoking Initialize() function of class.
Python module <Class.py> :
def test():
print "Test called"
return 1
class ClassTest:
def __init__(self)
def Initialize ():
print " Initialize called"
return 1
@staticmethod
def Execute():
print "Execute called"
return 1
C# Console Programme code snapshot :
PythonEngine.Initialize();
using (Py.GIL())
{
PyObject testClassModule =
PythonEngine.ImportModule("Class");
//Calling module method
PyObject result = testClassModule.InvokeMethod("test");
Console.WriteLine("Test method result = {0}",
result.ToString());
PyObject classTest = testClassModule.GetAttr("ClassTest");
*classTest.InvokeMethod("Initialize ");
-----------------------------> Error*
classTest.InvokeMethod("Execute");
}
PythonEngine.Shutdown();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pythondotnet/attachments/20180425/ac4489ea/attachment.html>
More information about the PythonDotNet
mailing list