Created
October 13, 2011 17:51
-
-
Save bfroehle/1284927 to your computer and use it in GitHub Desktop.
printf alternative in Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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