Skip to content

Instantly share code, notes, and snippets.

Created October 13, 2011 17:51
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::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