I am trying to get input from a user on the command line. The program reads data from a text file in the form of "cat text.txt | ./thescript.py"
At the point of the script in question, all data has already been read, processed and placed in a list of lists.
Now I repeat the list of lists looking for questionable items. The code basically looks like this:
for invoice in parsedlist: if invoice[-1] == 3: sys.stderr.write("triple duplicate at " + invoice[2]+' : ' + invoice[3]+"\n") sys.stderr.write("continue Y or N \n") answer = raw_input("Type your answer here") if answer == 'N': sys.exit(1) else: pass`
This code raises an EOFError. From what I already understand, stdin is reading from cat in this case, and since it has already reached EOF, so raw_input gets EOF here? (I think) The goal is for the script to print a standard error warning and allow me to ignore the warning and continue or close completely. At the end, all output is output and will not contain any error warnings or responses. I saw examples that use try / exception, but I could not figure it out in this context. (For example, why does raw_input not wait for input?)
I think that I can simply attack this problem in no other way and thus create a problem that could be better resolved then jumped over. Any help is appreciated, as always.
Wyatt
source share