IJCdelpi 0 Posted February 20, 2023 Hello, My question is a bit of a novice question because I am kind of new to Delphi and I just started using this library. I am just trying to pass 2 arguments from the python version of a function to the delphi version of the function. I have been using the Demos (demo 3) and the book linked in the readme in the P4D Git repo, but I am a little stuck/confused. I was able to get my really simple Python script to run if I pass 1 argument but if I try to pass 2 arguments to my function in the Python script this is the error I get: Quote Traceback (most recent call last): File "<string>", line 3, in <module> TypeError: read_AP_register() takes exactly 1 argument (2 given) Here are the snippets of code: Quote //Delphi Code: procedure TForm1.PythonModule1Events0Execute(Sender: TObject; PSelf, Args: PPyObject; var Result: PPyObject); Var arg1 : LongWord; arg2 : LongWord; output: LongWord; begin With GetPythonEngine Do Begin if PyArg_ParseTuple(Args, 'i:read_AP_register', @arg1, @arg2) <> 0 Then begin output := read_AP_register(arg1, arg2); Result := PyLong_fromLong(output); end Else begin Result := Nil; end; End; end; //this is just an nonsense example function function read_AP_register (arg1, arg2 : LongWord): LongWord; begin result := arg1 - arg2; end; //Python Script from delphi_module import read_AP_register result = read_AP_register(15, 10) print(result) If anyone has any suggestions or tips that could help out that would be really awesome! Thanks! -Ian Share this post Link to post
pyscripter 689 Posted February 21, 2023 56 minutes ago, IJCdelpi said: if PyArg_ParseTuple(Args, 'i:read_AP_register', @arg1, @arg2) <> 0 It should be 'ii:read_AP_register' if you are expecting two integer arguments. 1 Share this post Link to post