Hi gang, a strange one uncovered by a student of my
tutorial.
If you create the following example program, lets call it
intest.py:
####### intest.py #####
inp = raw_input()
while inp != '': print inp inp = raw_input() #######################
And the following data file
-------- Not part of in.txt -----
6
7
8
-------- Not part of in.txt -----
Then run Python from a DOS prompt like so:
C:\somepath> pythopn intest.py < in.txt
The file content is echo'd as expected.
But if you start it:
C:\somepath> intest.py < in.txt
There is no output!
In fact, I get an error:
E:\PROJECTS\Python>intest.py < in.txt
Traceback (most recent call last): File "E:\PROJECTS\Python\intest.py", line 2, in ? inp = raw_input() EOFError: EOF when reading a line And if you run
C:\somepath> intest.py
You get the interactive version as expected.
Why the difference with the redirected file? I am confused.
What am I missing? XP seems to have a different runtime
environment depending on how the script is run...
BTW This also happens under cygwin.
|
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor