Redirecting the output from sys.stdout
Mikael Olofsson
mikael at isy.liu.se
Tue Apr 11 07:14:15 EDT 2000
On 11-Apr-00 Oleg Broytmann wrote:
> import os, string
> pipe = os.popen("dir /w", 'r') # Open pipe for reading
>
> lines = []
> while 1:
> line = pipe.readline()
> if not line: break # EOF
>
> lines.append(line)
Why not the following?
import os, string
pipe = os.popen("dir /w", 'r') # Open pipe for reading
lines = pipe.readlines()
Or even the following to throw away the pipe when you are done with it.
import os, string
lines = os.popen("dir /w", 'r').readlines()
/Mikael
-----------------------------------------------------------------------
E-Mail: Mikael Olofsson <mikael at isy.liu.se>
WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael
Phone: +46 - (0)13 - 28 1343
Telefax: +46 - (0)13 - 28 1339
Date: 11-Apr-00
Time: 13:09:36
This message was sent by XF-Mail.
-----------------------------------------------------------------------
More information about the Python-list
mailing list