Page 1 of 1

using a Python module from Harbour according to IA

Posted: Wed Dec 14, 2022 6:54 pm
by Antonio Linares
generated using https://beta.openai.com/playground

Code: Select all | Expand

#include "hbapi.h"

HB_FUNC( MAIN )
{
   Py_Initialize();

   PyObject* pName;
   pName = PyString_FromString( ( char * ) "my_module" );

   PyObject* pModule;
   pModule = PyImport_Import( pName );

   PyObject* pDict;
   pDict = PyModule_GetDict( pModule );

   PyObject* pFunc;
   pFunc = PyDict_GetItemString( pDict, ( char * ) "my_function" );

   PyObject* pArgs;
   pArgs = PyTuple_New( 1 );
   PyObject* pValue;
   pValue = PyInt_FromLong( 1 );
   PyTuple_SetItem( pArgs, 0, pValue );

   PyObject_CallObject( pFunc, pArgs );

   Py_DECREF( pName );
   Py_DECREF( pArgs );
   Py_DECREF( pModule );

   Py_Finalize();

   hb_retl( HB_TRUE );
}

Re: using a Python module from Harbour according to IA

Posted: Tue Mar 21, 2023 9:23 pm
by Antonio Linares
Using Python from Harbour, working :-)

https://github.com/FiveTechSoft/harbour_python

Re: using a Python module from Harbour according to IA

Posted: Mon Mar 27, 2023 12:30 pm
by toninhofwi
Wow!

Good news, today I'm using Chilkat because I need some features that Harbour don't have, for example XmlDSigGen,
using Pyton for sure there are no limitation to do this.

Thank you Antonio, best regards.