what does "lost sys.stdin" error mean?
lynvie
lyndiechiou at gmail.com
Thu Jun 11 17:50:32 EDT 2009
I have a very simple program from the first chapter of a book on
python 3 (I'm a novice). I called the program tmp.py and the data
input file is sum.dat (just a list of numbers, 1 per line). When I
type into my command shell "tmp.py < sum.dat" I get an error from
"line=input()" -- that's line 7 from the code below. The exact error
message is:
RuntimeError: input(): lost sys.stdin.
print("Type integers, each followed by Enter; or ^D or ^Z to finish")
total=0
count=0
while True:
try:
line=input()
if line:
number=int(line)
total += number
count += 1
print("number =",number)
except ValueError as err:
print(err)
continue
except EOFError:
break
if count:
print("count =", count, "total =", total, "mean =", total/
count)
More information about the Python-list
mailing list