Python, Tkinter and popen problem

Peter Otten __peter__ at
Fri May 29 02:27:34 EDT 2009

norseman wrote:

> The direct question comes back to:
> How does one force a sync or flush() to take effect in Python with
> Tkinter in use? Or just in Python period. The keyword being force.

Here's some truly minimal code which shows the same buffering behaviour:

$ cat
#!/usr/bin/env python
import os
for line in os.popen("./"):
    print "-->", line.strip()

$ cat
#!/usr/bin/env python
import time

for i in range(5):
    print i

On Linux you can work around it with pexpect:

$ cat
#!/usr/bin/env python
import pexpect
for line in pexpect.spawn("./"):
    print "-->", line.strip()

On Windows, I don't know.


More information about the Python-list mailing list