Unbuffer stdout?

Jp Calderone exarkun at intarweb.us
Wed Mar 26 00:08:06 EST 2003


On Tue, Mar 25, 2003 at 07:24:43PM -0500, Francis Avila wrote:
> I'm trying to run the stdout of an os.popen*() to sys.stdout.  Problem is
> that the output seems to get trapped in a buffer until the command exits.
> 

    i = os.popen("yes", "r", 0).readline
    o = sys.stdout.write
    while 1:
       o(i())

  Jp

-- 
Seduced, shaggy Samson snored.
She scissored short.  Sorely shorn,
Soon shackled slave, Samson sighed,
Silently scheming,
Sightlessly seeking
Some savage, spectacular suicide.
                -- Stanislaw Lem, "Cyberiad"
-- 
 up 6 days, 1:59, 1 user, load average: 0.12, 0.10, 0.03





More information about the Python-list mailing list