Boost
C++ Libraries
...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
importExposes a mechanism for importing python modules.
import
object import(str name);
name.
#include <iostream>
#include <string>
using namespace boost::python;
void print_python_version()
{
// Load the sys module.
object sys = import("sys");
// Extract the python version.
std::string version = extract<std::string>(sys.attr("version"));
std::cout << version << std::endl;
}
Revised 01 November, 2005
© Copyright Stefan Seefeld 2005.