I added a static function named pyCall to the Pynet class. It works very well when testing the example code in LA, but it doesn't work in QM.
string code = """
def Multi(a1, a2):
return a1 * a2
""";
var a = Pynet.pyCall(code, "Multi", 6, 7);
print.it(a);
qm code:
QM Err info:
0x80004002, Interface not supported.
The specified conversion is invalid.
string code = """
def Multi(a1, a2):
return a1 * a2
""";
var a = Pynet.pyCall(code, "Multi", 6, 7);
print.it(a);
public static object pyCall(string code, string func = null, params object[] args)
{
using (var pyn = new Pynet(code))
{
dynamic m = pyn.Module;
var pyFunc = m.GetAttr(func);
PyObject[] pyArgs = args.Select(arg => arg.ToPython()).ToArray();
using (var result = pyFunc.Invoke(pyArgs))
{
return result.AsManagedObject(typeof(object));
}
}
}
qm code:
ARRAY(VARIANT) args.create
sel getopt(nargs)-1
,case 1 args[]=_A1
,case 2 args[]=_A1; args[]=_A2
,case 3 args[]=_A1; args[]=_A2; args[]=_A3
,case 4 args[]=_A1; args[]=_A2; args[]=_A3; args[]=_A4
,case 5 args[]=_A1; args[]=_A2; args[]=_A3; args[]=_A4; args[]=_A5
ret x.Call("Pynet.pyCall" code _Func args)
QM Err info:
0x80004002, Interface not supported.
The specified conversion is invalid.