python -i <script.py>
is theoretically meant to run script.py
and proceed into interactive mode, however:
shell$ python -i print_content.py < file.txt
hello world
>>>
shell$
The script runs successfully and is followed by printing >>>
, implying that the Python shell is entered following script execution.
I know I could bypass the issue by opening the file from within the script - I'm more curious to know the cause of the issue.
Note: Contents of print_content.py seem innocent enough:
import sys
for i in sys.stdin:
print i
Note: I'm using Python 2.7.3