Connecting Tech Pros Worldwide Forums | Help | Site Map

Re: Best way for add new path when embedding python into C

Christian Heimes
Guest
 
Posts: n/a
#1: Sep 1 '08
Pau Freixes wrote:
Quote:
The best way for add new path before call PyImport_Import is adding new
string item into sys path object ?
The same way you'd add a path in Python:


PyObject *sys_path;
PyObject *path;

sys_path = PySys_GetObject("path");
if (sys_path == NULL)
return NULL;
path = PyString_FromString("/your/path")
if (path == NULL)
return NULL;
if (PyList_Append(sys_path, path) < 0)
return NULL
Py_RETURN_NONE;


Christian


Closed Thread