Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
printf alternative in Python
#include <boost/python.hpp>
void report(std::string msg) {
PyObject *f = PySys_GetObject((char *)"stdout");
PyFile_WriteString(msg.c_str(), f);
PyFile_WriteString("\n", f);
}
BOOST_PYTHON_MODULE(reporting) {
boost::python::def("report", &report);
}
from reporting import report
report("It Works!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment