Something that Perl can do that Python can't?
gsakkis at rutgers.edu
Sat Jul 23 01:31:49 CEST 2005
"Dr. Who" <google at spiceaid.com> wrote in message
news:1122066437.870669.58990 at z14g2000cwz.googlegroups.com...
> Well, I finally managed to solve it myself by looking at some code.
> The solution in Python is a little non-intuitive but this is how to get
> while 1:
> line = stdout.readline()
> if not line:
> print 'LINE:', line,
> If anyone can do it the more Pythonic way with some sort of iteration
> over stdout, please let me know.
You can use the sentinel form of iter():
for line in iter(stdout.readline, ''):
print 'LINE:', line,
More information about the Python-list