You may get more feedback on stackoverflow than on this mailing list for questions like this:On Fri, Apr 27, 2018 at 3:54 AM, techi eth <techieth@gmail.com> wrote:Any input on raised query. I think i am missing something very simple but not able to catch.ThanksOn Thu, Apr 26, 2018 at 5:47 PM, techi eth <techieth@gmail.com> wrote:Yes,It will work with this way but i need to create multiple instance of same class.If you see other function (@Execute() ) with static was working.Please give me hint of doing without static.ThanksOn Thu, Apr 26, 2018 at 4:54 PM, Stefan Schukat <SSchukat@dspace.de> wrote:______________________________Hello,
you missed either @staticmethod decorator or the self argument for the Initialize method.
Stefan
From: PythonDotNet [mailto:pythondotnet-bounces+s
schukat =dspace.de@python.org] On Behalf Of techi eth
Sent: Wednesday, April 25, 2018 2:38 PM
To: A list for users and developers of Python for .NET <pythondotnet@python.org>
Subject: [Python.NET] Error in calling Python class method from C#
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("Cla
ss");
//Calling module method
PyObject result = testClassModule.InvokeMethod("
test"); Console.WriteLine("Test method result = {0}", result.ToString());
PyObject classTest = testClassModule.GetAttr("Class
Test"); classTest.InvokeMethod("Initia
lize "); -----------------------------> Error classTest.InvokeMethod("Execut
e"); }
PythonEngine.Shutdown();
___________________
Python.NET mailing list - PythonDotNet@python.org
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
Python.NET mailing list - PythonDotNet@python.org
https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
Python.NET mailing list - PythonDotNet@python.org
https://mail.python.org/mailman/listinfo/pythondotnet