Hi all, I have a question on subprocess.Popen, as shown comparably below. When I ran 1.py, it prints "0". I don't understand how the file is empty. Isn't it flushed when the file object "out" is closed? On the other hand, running 2.py prints correct value.
####### 1.py ########## from subprocess import * out = open('foo.t', 'w') a = Popen('ls -l', shell = True, stdout = out) out.close() print len(open('foo.t').readlines()) ##### 2.py ######### from subprocess import * out = open('foo.t', 'w') a = Popen('ls -l', shell = True, stdout = PIPE, stderr = PIPE) print >> out, a.communicate()[0] out.close() print len(open('foo.t').readlines()) Thanks -- Best, Zhenjiang
-- http://mail.python.org/mailman/listinfo/python-list