Py_SetProgramName?

Alex Martelli aleaxit at yahoo.com
Mon Feb 19 11:15:54 EST 2001


"Owen F. Ransen" <ransen_spam_me_not at nemo.it> wrote in message
news:3a913b2f.4245179 at news.newsguy.com...
> Embeddinga and Extending, I'm not sure of the reasons
> for calling :
>
>    Py_SetProgramName
>
> Is it for getting the command line arguments of
> a C program calling Python? Or for something to
> do with the search path of modules?

The latter.  Quoting from "1.4, Embedding Python" in
the Python/C API Reference Manual:

"""
The embedding application can steer the search by
calling Py_SetProgramName(file) before calling
Py_Initialize(). Note that $PYTHONHOME still overrides
this and $PYTHONPATH is still inserted in front of the
standard path. An application that requires total
control has to provide its own implementation of
Py_GetPath(), Py_GetPrefix(), Py_GetExecPrefix(),
and Py_GetProgramFullPath() (all defined in
Modules/getpath.c).
"""

If your embedding application wants to set the
sys.argv list, it can do so, quite separately
from Py_SetProgramName, by calling
PySys_SetArgv(argc, argv) *after* it calls
Py_Initialize.


Alex






More information about the Python-list mailing list