AW: [C++-sig] Stdout from c++

Stefan Seefeld seefeld at sympatico.ca
Wed Nov 5 17:11:17 CET 2003


Oliver Walczak wrote:
> Dear Stefan,
> Writing to the idle console from a dll certainly IS a task of python
> programming under c++. And i can't really believe that anyone writing .pyd's
> needs to reconnect std.cout with it's own streambuf class by hand when
> python provides modules to create a webserver in three rows of code, do you?
> Are you really shure that there is no python api functionality for this?


ok, may be I replied a bit to quickly. Sorry.

Python's C API has a couple of functions to write to stdout.

What I said earlier is still true: std::cout is a global object that is
not automagically reconnected to any 'console' you may provide. You have
to do that yourself. So the solution I suggested still seems valid:
Write a streambuf class that uses the python C API in its 'overflow'
call, and then reset std::cout.rdbuf() to use that.

Regards,
		Stefan






More information about the Cplusplus-sig mailing list