On Fri, Apr 27, 2012 at 3:57 AM, Peter Faulks <faul...@iinet.net.au> wrote: > 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") > --------------- > Is this feasible?
Absolutely. > Any gotchas I should be aware of? Yes, one. Make sure you use Python 3, not Python 2. Then all you have to do is assign to print, which is a function like any other. Alternatively, replace sys.stdout - untested but I'm pretty sure that will work just as well. ChrisA PS. What on earth are you doing at 4AM on a Friday? Oh wait. What am I doing at 4AM on a Friday? We both seem to be nocturnal Australians here... -- http://mail.python.org/mailman/listinfo/python-list