Skip to content

Instantly share code, notes, and snippets.

@bfroehle
Created October 13, 2011 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bfroehle/1284927 to your computer and use it in GitHub Desktop.
Save bfroehle/1284927 to your computer and use it in GitHub Desktop.
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