I have a script which sometimes will take input as files, like so:
python prog.py < file1
I then have a loop which takes the input:
mode = os.fstat(0).st_mode While True: if stat.S_ISREG(mode): r = sys.stdin.readlines() inp = input()
In the above code I check whether the file is redirected. If it is I take all the input and send it to a list.
This works fine, it takes the input from file1 and puts it in the list. However after that I would like to accept user input again. But when I try call input() it just raises and EOF exception because I took everything out of the file.
How can I tell stdin to start accepting user input again?
This post has been edited by jp612: 18 August 2014 - 01:01 AM