I have a python script that I call redirecting it to Django manage.py shell
.
$ python manage.py shell < script.py
I want to take an answer from user to decide what to do. But I can't do it neither with input()
or sys.stdin.readline()
.
With input()
answer = input('A question')
if answer == 'y':
# Do something
else:
pass
Error:
EOFError: EOF when reading a line
With sys.stdin.readline:
answer = sys.stdin.readline()
if answer == 'y':
# Do something
else:
pass
In this case script continues without wait for user input.
What's the correct way for doing that?