Module import path when embedding python in C

G

graph

Per http://mail.python.org/pipermail/python-list/2008-September/506206.html
something like this (plus error handling) seems to be the right way to
add to sys.path when embedding python in C:

PyObject *sys_path = PySys_GetObject("path");
PyObject *path = PyString_FromString("/your/path");
PyList_Append(sys_path, path);

Does anyone know why PySys_GetObject wasn't documented until somewhat
recently (http://bugs.python.org/issue1245) if it has been part of the
system module interface since at least Python 1.5.2? Is it not
supposed to be used? What's the difference the above and importing
the sys module and then doing the append?

Thanks in advance.

-g
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top