Eric Lavigne wrote: > Here is a shell command (MS-DOS): > debug\curve-fit <input.txt >output.txt > > And here is a Python script that *should* do the same thing (and almost > does):
Python equivalent is roughly: import os import subprocess subprocess.Popen([os.path.join("debug", "curve-fit")], stdin=file("input.txt"), stdout=file("output.txt", 'w')).wait() > import os > > inputfilename = 'input.txt' > outputfilename = 'output.txt' > > inputfile = open(inputfilename,'r') > outputfile = open(outputfilename,'w') > inputstream,outputstream = os.popen2("debug\\curve-fit") > inputstream.write(inputfile.read()) > inputfile.close() > inputstream.close() > outputfile.write(outputstream.read()) > outputstream.close() > outputfile.close() > > In the shell command, my curve-fit program processes the entire input > file. In the Python script, my curve-fit program processes all except > for the last line. Adding an extra newline to the end of my input file > fixes this problem. What did I do wrong that led to this small > difference? No idea. Your version works fine for me. -- http://mail.python.org/mailman/listinfo/python-list