sys.stdout linebuffered

Thomas Guettler guettli at thomas-guettler.de
Wed May 26 10:43:45 EDT 2004


Am Wed, 26 May 2004 09:40:01 -0400 schrieb Peter Hansen:

> Thomas Guettler wrote:
> 
>> I start a long running script like this (unix):
>> 
>> nohup foo.py > foo.log &
> [snip]
>> The "-u" switch is not an option.
> 
> That statement is suspect, and like Benjamin I wonder whether
> it really is true.

I like to use #!/usr/bin/env

===> cat minus-u.py
#!/usr/bin/env python -u

===> ./minus-u.py
/usr/bin/env: python -u: No such file or directory

> Nevertheless, in the unlikely case that you
> absolutely cannot use the -u switch, look at the description of
> that option in the output of "python -h" and use the environment
> variable mentioned there instead.

The environment variable has the drawback,
that I need to set it before every call to this
script. Other scripts should not be unbuffered.

 Thomas




More information about the Python-list mailing list