Hi,
I'm using python to set up a rendering engine. The settings are stored in the script file as dictionary objects.
eg:
I'm trying to read this in C++ like thisCode:RenderInfo = {}; RenderInfo['Title'] = "Simple Python Board"; #window Title RenderInfo['ScreenWidth'] = 640; .... ....
All other types work, but the string's fail and return NULL. This is the first time I'm using the PyBytes_AsString function since it replaced PyString_AsString in version 3.1.Code:PyObject *renderInfo,*renderStats; renderInfo = PyDict_GetItemString(pDict,"RenderInfo"); renderStats = PyDict_GetItemString(renderInfo,"Title"); char* title = PyBytes_AsString(renderStats); //Also Tried PyBytesArray_AsString printf("%s\n",title); // Prints NULL renderStats = PyDict_GetItemString(renderInfo,"ScreenWidth"); int sw = PyLong_AsLong(renderStats); printf("%d\n",sw); // prints 640
Does Anyone know why this is not working ?
Thanks!



LinkBack URL
About LinkBacks


