using a Python module from Harbour according to IA

using a Python module from Harbour according to IA

Postby Antonio Linares » Wed Dec 14, 2022 6:54 pm

generated using https://beta.openai.com/playground

Code: Select all  Expand view
#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 );
}
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42081
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: using a Python module from Harbour according to IA

Postby Antonio Linares » Tue Mar 21, 2023 9:23 pm

Using Python from Harbour, working :-)

https://github.com/FiveTechSoft/harbour_python
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42081
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: using a Python module from Harbour according to IA

Postby toninhofwi » Mon Mar 27, 2023 12:30 pm

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.
toninhofwi
 
Posts: 172
Joined: Tue Oct 18, 2005 10:01 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 76 guests