[C++-sig] Creating a dictionary to pass to python
eXt at sidvind.com
Sat Jan 13 22:34:10 CET 2007
Stefan Seefeld skrev:
> David Sveningsson wrote:
>> Hi, using boost I would like to create a dictionary and pass it to
>> python. Is this possible?
> (To get a more substantial answer you'd need to provide a more substantial
> question. ;-) )
I might have partially solved it.
At the moment I use this code:
PyObject* m = PyDict_New();
PyDict_SetItem(m, PyString_FromString("test"), PyFloat_FromDouble(4.6f);
And have exported it like this:
But this seems to leak some memory. I guess I should use
manage_new_object as a return policy but when I do I get a segfault. It
seems like it tries to use free but should use delete instead.
Is this the "right" way or should I do it some other way? What about
//*David Sveningsson [eXt]*
Freelance coder | Game Development Student
Thou shalt make thy program's purpose and structure clear to thy fellow
man by using the One True Brace Style, even if thou likest it not, for
thy creativity is better used in solving problems than in creating
beautiful new impediments to understanding.
More information about the Cplusplus-sig