Embedding Python
Sébastien Boisgérault
Sebastien.Boisgerault at gmail.com
Fri Jun 17 10:58:46 EDT 2005
Hi,
Imagine that you have a PyObject pointer 'object'
pointing to a Python integer ... let's say 42.
How would do you attach the variable "answer" to
it so that the code
PyRun_SimpleString("print answer");
works as expected ?
My current solution is:
__main__ = PyImport_ImportModule("__main__");
PyObject_SetAttrString(__main__, "answer", object);
Anything better ?
SB
More information about the Python-list
mailing list