Boost logo

Boost Users :

Subject: [Boost-users] (Boost.Python) How to print from C++ to the same stream as Python's 'print' does?
From: Dietrich Bollmann (diresu_at_[hidden])
Date: 2009-05-11 12:11:56


Hi,

I would like to print from C++ to the same stream as Python's 'print'
command does. I am using an embedded Python shell and when using
std::cout nothing is printed at all...

Currently I am using the following code:

  std::ostringstream oss;
  oss << "test\n";
  std::string cs = oss.str();
  PySys_WriteStdout(cs.c_str());

I wonder if there is an easier way to get the same result?

Thanks, Dietrich


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net