> From: Bjorn Pettersen I hate to reply to myself...
> I'm trying to embed Python, which is working nicely, however > I also want to access objects from my SIP wrapped library > from Python. I tried the following code: > > int main() { > Py_Initialize(); Here I need to let Python load the module first: PyObject* strMod = PyString_FromString("NrxDataTypes"); PyObject* mod = PyImport_Import(nrx); and for the PyImport_Import to succeed in debug mode, the .dlls must be named foo_d.dll and libsip_d.dll, and the SIP generated NrxDataTypes.py module needs to be in the module search path. > initlibsip(); > initlibNrxDataTypesc(); > > NDate value(2002, 5, 28); PyObject* dict = PyDict_New(); PyObject* tmp = PyString_FromString("tmp"); > PyObject* val = sipMapCppToSelf(&value, sipClass_NDate); PyDict_SetItem(dict, tmp, val); PyObject* res = PyRun_String("2 + tmp.getYear()", eval_input, dict, dict); long result = PyInt_AsLong(res); It still doesn't work however. I get a Fatal Python error: PyEval_SaveThread: NULL tstate If anyone knows what could cause this, I would appreciate a pointer :-) In the meantime I'll try to dig into it myself... -- bjorn _______________________________________________ PyKDE mailing list [EMAIL PROTECTED] http://mats.gmd.de/mailman/listinfo/pykde