bufsize in subprocess
yves at zioup.com
yves at zioup.com
Sun Jan 22 11:43:41 EST 2012
On 2012-01-22 00:27, Chris Rebert wrote:
> On Sat, Jan 21, 2012 at 9:45 PM,<yves at zioup.com> wrote:
>> Is this the expected behavior?
>
> Yes. `.read()` [with no argument] on a file-like object reads until
> EOF. See http://docs.python.org/library/stdtypes.html#file.read
Right, got it now.
> You want proc.stdout.readline().
Yes, or a for loop, this works for me now:
import subprocess
com = ['/bin/ls', '-l', '/usr/bin']
with subprocess.Popen(com, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT) as proc:
for line in proc:
print('out: ' + str(line, 'utf8'))
--
Yves. http://www.SollerS.ca/
http://ipv6.SollerS.ca
http://blog.zioup.org/
More information about the Python-list
mailing list