Reading from stdin (in windows)

Rob Williscroft rtw at
Tue Oct 14 13:43:01 CEST 2008

durumdara at wrote in news:mailman.2448.1223974725.3487.python-
list at in comp.lang.python:

> Hi!
> I wanna write a file processor in python (Windows XP).
> I wanna use pipe, and not parameters.
> When I write this:
> ...
> l = []
> while 1:
>      t =
>      if t == '':
>          break
>      l.append(t)
> t = "".join(l)
> ...
> and use code this:
> <test.txt
> I got:
> "Bad file descriptor"
> What I do wrong? I need to call this module in another format?
> Or I read in wrong way?

The problem appear to be that MS-Windows doesn't make pipe's for 
programs it opens via its file type association mechanism.

Essentially MS-Windows is treating the .py file as a document and
using python to "open" the document.

Try running you program as:

python <test.txt

Note for this to work python will have to be on your path.  If
it isn't use the full path to you copy of python. for e.g.:

c:\python25\python.exe <test.txt


More information about the Python-list mailing list