Cheers,
Yes was aware this would (might) be possible in 3.x only.
"All you have to do is assign to print". Sounds great! Can some kind
soul hit me with a clue stick? Were do I look in the API?
On 27/04/2012 4:26 AM, Chris Angelico wrote:
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