The contents of the file a.py are:
a = input()
and fearless.txt contains the string : pink floyd.
Now, when I simply type in
%a.py < fearless.txt at the command prompt (windows), it gives an error "lost.stdin".
However, when I type
%python a.py < fearless.txt, no error occurs.
I don't understand this, given that .py is a recognized extension and is run by python. Shouldn't then, both be equivalent? Note I'm using the symbol
% in place of the actual directory.
( Python version : 3.4.3:9b73f1c3e601 and winXP-32 bit. )
Best How To :
It depends a bit on how the
.py files are registered. It should work when the
py.exe launcher is set up correctly. You can verify this by looking up the following key in the registry:
HKEY_CLASSES_ROOT\Python.File\shell\open\command. The default value should be
"C:\WINDOWS\py.exe" "%1" %*.
You can also try using the following instead:
type fearless.txt | a.py
I just noticed that you are using Windows XP. The problem you are seeing might be because of an old Windows bug with redirection. It was said to be fixed at some point, but maybe XP was still partially affected. I suggest you to update your system anyway because Windows XP is no longer supported by Microsoft.