Python, Tkinter and popen problem
Peter Otten
__peter__ at web.de
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 master.py
#!/usr/bin/env python
import os
for line in os.popen("./child.py"):
print "-->", line.strip()
$ cat child.py
#!/usr/bin/env python
import time
for i in range(5):
print i
time.sleep(.2)
On Linux you can work around it with pexpect:
$ cat master2.py
#!/usr/bin/env python
import pexpect
for line in pexpect.spawn("./child.py"):
print "-->", line.strip()
On Windows, I don't know.
Peter
More information about the Python-list
mailing list