Reputation: 3559
I am using python's very high level layer to embed some python code to a commercial application that supports a proprietary scripting language. The problem is that the application itself is coded in C++ and it has a embedded log window which displays cout and cerr. I was wondering if there is a way to print to cout/cerr from python... I already goggled a lot about it, but I cannot find a simple way to do it.
Thanks!
Upvotes: 1
Views: 2310
Reputation: 799580
There is no simple way. The application itself must assign file-likes to sys.stdout
and sys.stderr
in order to capture them.
Upvotes: 1
Reputation: 4448
You can do it using these calls:
import sys
sys.stderr.write('blah blah\n')
sys.stdout.write('blah blah\n')
or alternatively using these ones:
print >> sys.stderr, 'blah blah'
print >> sys.stdout, 'blah blah'
Upvotes: 0