FAQ
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

Search Discussions

  • Christian Heimes at Sep 26, 2008 at 8:24 am

    graph wrote:
    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?
    The PySys_Get/SetObject methods are faster than PyImport. The methods
    access the sys module directly without going through the import API. The
    funcitons weren't documented because they were simply forgotten.

    Christian

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedSep 26, '08 at 6:55a
activeSep 26, '08 at 8:24a
posts2
users2
websitepython.org

2 users in discussion

Graph: 1 post Christian Heimes: 1 post

People

Translate

site design / logo © 2022 Grokbase