Using Python4Delphi, it is fairly straight forward to expose Delphi methods to Python so that Python can call into a Delphi application. However I have been unable to return a Python list that is created by a Delphi method to Python. For example:
function TDelphiAPI.callMethod : PPyObject;
begin
// Create a new empty list of three elements
result := GetPythonEngine.PyList_New(3);
end;
import mylib
p = mylib.DelphiAPI()
print p.callmethod()
This returns 'NoneType' when called from Python. If PPyObject is changed to a type such as integer, AnsiString or double, Python picks up the correct type and displays it correctly. I use
GetPythonEngine.AddMethod ('callMethod', @TDelphiAPI.callMethod, 'callMmethod)');
to expose the method from Delphi. However there is no way to specify the types for either the arguments or return type, as far as I can tell.
I am wondering if anyone has returned from delphi python types such as lists or even numpy arrays?