redirect sys.stdout to C++ ?

André Jonsson tatsujin at despammed.com
Sat Dec 28 09:17:23 EST 2002


Bengt Richter wrote:
> 
> Some time ago I ran into (what I at least thought was) a bug in the use of softspace
> in interactive mode. Perhaps your problem is related. See (posted 2002-07-16)
> 
>     http://groups.google.com/groups?selm=ah2887%24bpu%240%40216.39.172.122&output=gplain
> 
    <snip>
> 
> I don't know if this is at the root of your problem, but it reminded me.

Thanks for informing me. I tried adding a 'softspace' attribute to the redirection 
class. When setting it to False it behaves just like without it (I guess it's 
default), and setting it to True, omits all trailing newline characters. This is 
consistent, but it's a bit awkward/difficult to find out when a string has ended and 
should be displayed...

I should probably make clear that I don't use an actual "interactive shell", I just 
feed an entered string into the PyRun_SimpleString() API call, thus the normal 
interactive echoing isn't available (e.g. just typing dir() won't output anything). 
Only things output with print or things sent to sys.std(out|err) is displayed 
(through my callback). Is there something more that should/can be redirected for this 
to work correctly?


/André






More information about the Python-list mailing list