Embedded Python 2.7.2 Importing a module from a user-defined directory
问题 I'm embedding Python into a C/C++ application that will have a defined API. The application needs to instantiate classes defined in a script, which are structured roughly like this: class userscript1: def __init__(self): ##do something here... def method1(self): ## method that can be called by the C/C++ app...etc I've managed in the past (for the proof-of-concept) to get this done using the following type of code: PyObject* pName = PyString_FromString("userscript.py"); PyObject* pModule =