Stdout in extensions under IDLE
Michal Wallace
sabren at manifestation.com
Thu Oct 5 14:13:15 EDT 2000
On Thu, 5 Oct 2000, Jeff Perry wrote:
> My C extension's output is different under the python command line shell
> than it is under the graphical shell, IDLE.
>
> pyext.c:
> #include <stdio.h>
> void Print() { printf("This is the message.\n"); }
Sure.. because in a shell, you're actually looking at STDOUT.. In
IDLE, you don't see it at all..
python's "print" statement doesn't necessarily go to the real STDOUT,
it goes to whatever sys.stdout is pointing to.. So sys.stdout can be
redirected to somewhere else, like an IDLE window.. But it doesn't
monitor the REAL STDOUT, so if your C extension just calls printf, it
bypasses python altogether..
I don't know too much about C extensions, but I bet there's a way
to talk to sys.stdout defined somewhere in python.h... :)
Cheers,
- Michal
------------------------------------------------------------------------
www.manifestation.com www.sabren.com www.linkwatcher.com www.zike.net
------------------------------------------------------------------------
More information about the Python-list
mailing list