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)
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to