Unbuffered stderr in Python 3

Wolfgang Maier wolfgang.maier at biologie.uni-freiburg.de
Wed Nov 4 05:43:18 EST 2015


On 04.11.2015 11:24, Steven D'Aprano wrote:
> On Wed, 4 Nov 2015 07:19 pm, Wolfgang Maier wrote:
>
>> On 04.11.2015 04:18, Steven D'Aprano wrote:
>>>
>>> This is one of the offending line from our code base:
>>>
>>> print('<4>Suspicious answer "{}"!'.format(answer), file=sys.stderr)
>>>
>>> So that ought to be terminated by a newline. And yet, the stderr output
>>> doesn't show up until the program exits.
>>>
>>
>> For me, that prints immediately. Where is your output going? Console,
>> file, ...?
>
> Going to stderr, like the whole thread is about :-)
>

I see :), but seriously, what I meant was: is it going to the console 
directly or is your code base redirecting sys.stderr to another buffered 
object first?

>
> The output does eventually show up written to the console, but only after
> Python exits.
>
>
>




More information about the Python-list mailing list