Printing Boost Python object
1 answer
Boost.Python does not ship with operator<<(ostream&, const object&)
, but we can write our own to simulate what Python would do initially: call str
:
namespace py = boost::python;
std::ostream& operator<<(std::ostream& os, const py::object& o)
{
return os << py::extract<std::string>(py::str(o))();
}
+6
source to share