redirect sys.stdout to C++ ?

Bengt Richter bokr at oz.net
Sat Dec 28 11:49:09 EST 2002


On Sat, 28 Dec 2002 15:17:23 +0100, =?ISO-8859-1?Q?Andr=E9_Jonsson?= <tatsujin at despammed.com> wrote:

>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
<side issue>I think it gets added whether you like it or not, though it might be interesting to
see what it does if you prevent its creation using slots. </side issue>
>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 
         ^^^^^^^^^^^^^^ entered where & how? If it is in the same interpreter,
perhaps a similar thing could happen.

>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?

Need more context to understand your problem. Can you reduce it to a minimal example
showing how "entered strings" are entered and wind up being passed to PyRunSimpleString()?

Regards,
Bengt Richter



More information about the Python-list mailing list