(3.2) Overload print() using the C API?

Stefan Behnel stefan_ml at behnel.de
Fri Apr 27 03:15:32 EDT 2012


Peter Faulks, 26.04.2012 19:57:
> I want to extend an embedded interpreter so that calls to print() are
> automagically sent to a C++ gui (windows exe) via a callback function in
> the DLL.
> 
> Then I'll be able to do this:
> 
> ----test.py----
> import printoverload
> 
> printoverload.set_stdout()
> printoverload.set_stderr()
> 
> print("this will be sent to a C function in printoverload.pyd")
> ---------------

Why would you want to divert only "print" instead of changing sys.stdout in
general? Not all output comes from print calls.

Stefan




More information about the Python-list mailing list