On 27/04/2012 5:15 PM, Stefan Behnel wrote:
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
Because I don't want to have to poll the stdout buffer. I want the
script itself to update a window in the host application (via the
extension) every time the script calls print().
But I guess that won't work if the script raises an exception...
This is doing my head in. :)
--
http://mail.python.org/mailman/listinfo/python-list