Dave wrote: Why struggle? This should be: object /* Returns a borrowed reference */ getPythonFunction(string moduleName,string functionName) { object _module(handle<>( PyImport_ImportModule(const_cast<char*>(moduleName.c_str())))); <<-- line 63 in Main.cpp return _module.attr(functionName.c_str()); } ------------------------------------------------------------------------ Always a good question. The code doesn't compile as presented. I added #include <boost/python/object.hpp> to my module, have completely opened the boost::python namespace. Get the error: Main.cpp:63: error: variable declaration is not allowed here If I just instanciate an empty object with its default constructor, the module compiles. An underlining concern I have is error handling. When PyImport_ImportModule fails, a NULL pointer is returned. Seems like the underlining machinery in "handle<>" is intolerant of this.