Question about stdin and PATHEXT on Windows XP

Lasse Vågsæther Karlsen lasse at
Sat Oct 1 20:02:17 CEST 2005

I got a loop like this:

     while True:
         line = sys.stdin.readline()
         if not line:
         line = line.rstrip()
         log_message(options.channel_name, line)
         print line

this loop will read text if I execute it from a command prompt like this:

dir | python.exe

however, since I've set PATHEXT to contain .PY, I tried this:

dir |

which ended up with the loop just skipping.

Does anyone know how to fix this problem ? Being able to use PATHEXT 
execution (just execute python file directly) and still being able to 
grab stdin? I assume that since there is some magic involved in invoking 
python.exe here, stdin gets munged on the way.

Lasse Vågsæther Karlsen
mailto:lasse at
PGP KeyID: 0x2A42A1C2

More information about the Python-list mailing list