python3 reset stdin after end of file

Viewed 154

On Linux, I want to read from stdin where stdin comes first from pipe and then from user input. So the command looks like:

cat my-file | ./my-prog.py

After reading all the lines from the pipe:

inf = open(0, "r")
inf.readlines()

I want to get further input from user. I do it with input(). But I get EOFError: EOF when reading a line. I need a way to reset the stdin before the call to input(). Trying sys.stdin.seek(0) gives

io.UnsupportedOperation: underlying stream is not seekable

I read that in c there is clearerr that do that but I was not able to find how to do it in python.

0 Answers
Related