Module import path when embedding python in C

Discussion in 'Python' started by graph, Sep 26, 2008.

  1. graph

    graph Guest

    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 ( 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.

    graph, Sep 26, 2008
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page