[C++-sig] Passing an instance...

Beau Sapach beau.sapach at ualberta.ca
Fri Nov 3 19:27:52 CET 2006


Hello everyone,

 

I've got a C++ object that I've created a Python type for.  When I insert
the object into the main module using PyModule_AddObject then I can
instantiate it in Python and everything works just fine.  I assumed (mostly
from reading other's code) that I could use something like:

 

PyDict_SetItemString(MainDict,"x",pMyObject)

 

To get a variable called "x" into my python environment that IS the same
instance as that pointed to by pMyObject.  Then by running
PyRun_SimpleString("x.somefunction()\n") I could make use of pMyObject from
within Python.  This doesn't work, my application crashes.  What is the best
way to accomplish this using the Py??? functions from the Python API?

 

Beau

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20061103/7e0b5505/attachment.htm>


More information about the Cplusplus-sig mailing list