Something that Perl can do that Python can't?
George Sakkis
gsakkis at rutgers.edu
Fri Jul 22 19:31:49 EDT 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
> it:
>
> while 1:
> line = stdout.readline()
> if not line:
> break
> print 'LINE:', line,
>
> If anyone can do it the more Pythonic way with some sort of iteration
> over stdout, please let me know.
>
> Jeff
You can use the sentinel form of iter():
for line in iter(stdout.readline, ''):
print 'LINE:', line,
George
More information about the Python-list
mailing list