last line chopped from input file
jeffrey.schwab at rcn.com
Sun Aug 21 22:09:49 CEST 2005
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
Python equivalent is roughly:
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")
> 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
No idea. Your version works fine for me.
More information about the Python-list