Can I run a c++ object in Python program?
Fredrik Lundh
effbot at telia.com
Thu Feb 24 10:05:42 EST 2000
More information about the Python-list mailing list
Thu Feb 24 10:05:42 EST 2000
- Previous message (by thread): Can I run a c++ object in Python program?
- Next message (by thread): Fast way to grab line from file?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Bing Chen <BC at prism.co.nz> wrote: > I pass a object from c++ to Python as follow: > PyObject *pargs = Py_BuildValue("Oli",m_curr,field.first,field.second); > PyObject *pdict, *pval; > pdict = PyDict_New(); > PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins()); > > PyDict_SetItemString(pdict, "Y", pargs); /* dict['Y'] = pargs */ > PyRun_String("from BaseModule import *", file_input, pdict, pdict); > PyRun_String("X = BaseModelLink(Y)", file_input, pdict, pdict); > > the "m_curr" is an instance of class in my application, when I run some > method in the Python program as follow: /.../ it crash. probably because that instance isn't really PyObject* compatible... if I were you, I'd wrap the C++ classes using SWIG: http://www.swig.org </F>
- Previous message (by thread): Can I run a c++ object in Python program?
- Next message (by thread): Fast way to grab line from file?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list