I'm trying to get the script that asks for the input to work when stdin is redirected. It could be that this is not even possible, but I would like to understand why. Here is an example:
$ echo 'q = raw_input("question ?"); print "\ngot: ", q' | python - < <(echo answer) Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'answer' is not defined
I know I can get it to work with this:
$ python <(echo 'q = raw_input("question ?"); print "\ngot: ", q') < <(echo answer) question ? got: answer
but this is a process substitution. Is it possible to get it to work only with redirection?