peschü
peschü

Reputation: 1359

How to set sys.argv in a boost::python plugin

I use boost::python to integrate Python into a C++ program. Now I would like that the Python program that is executed via boost::python::exec_file() can obtain the command line arguments of my C++ program via sys.argv. Is this possible?

Upvotes: 3

Views: 893

Answers (1)

Brian Cain
Brian Cain

Reputation: 14619

Prior to your call to exec_file() (but after Py_Initialize(), you should invoke PySys_SetArgv(argc, argv); giving it the int argc and const char *argv[] from your program's main().

Upvotes: 2

Related Questions