From denis.akhiyarov at gmail.com Tue Jan 6 15:53:18 2015 From: denis.akhiyarov at gmail.com (Denis Akhiyarov) Date: Tue, 6 Jan 2015 08:53:18 -0600 Subject: [Python.NET] Python class instance from C# Message-ID: Does anyone have an example of using Python.NET in embedding scenario for creating an instance of a Python class/object, possibly with arguments passed to __init__() and then using this instantiated class to call its methods? The workaround for me right now is calling Python wrapper function that returns new instance of this class. I have an example that does NOT work for me: IntPtr pyobj = default(IntPtr); IntPtr u_name = Runtime.PyUnicode_FromString(ModuleName); IntPtr module = Runtime.PyImport_Import(u_name); IntPtr pyclass = Runtime.PyObject_GetAttrString(module, ObjectName); if (Runtime.PyCallable_Check(pyclass) == 1) { pyobj = Runtime.PyObject_CallObject(pyclass, pyargtuple); } IntPtr inst = Runtime.PyObject_Call(pyobj, IntPtr.Zero); PyObject result = new PyObject(inst); return result; -------------- next part -------------- An HTML attachment was scrubbed... URL: