[fpc-pascal] Python interaction... how?

leledumbo leledumbo_cool at yahoo.co.id
Fri Feb 16 09:56:46 CET 2018


> Does anyone know of a minimal example or pseudo code or just an
explanation?

Python actually provides a Python.h that you can convert to a Pascal unit.
But inside, it includes a bunch of other header files and conversion might
be a tedious task. If you made it, though, simply call:

Py_Initialize();
Py_WhateverThereAreMultipleChoicesHere(ProbablyAPythonScriptAsCString);
Py_Finalize();

and you're done.

But if I have to, I would take the external program approach instead using
its interpreter's -c option through TProcess. Communication will then be
done through pipes. It's probably slower, but quicker to work. If you take
the header conversion approach, however, that might benefit everyone else
needing to do the same, just like how the Lua bindings are done (but they're
a lot cleaner that makes conversion simpler).



--
Sent from: http://free-pascal-general.1045716.n5.nabble.com/


More information about the fpc-pascal mailing list