[Tutor] Simple question on creating a filter

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Fri Feb 11 20:35:41 CET 2005



On Fri, 11 Feb 2005, Smith, Jeff wrote:

> I'm sorry to both with such a simple question but I've looked in the
> normal places and don't see the quick and dirty answer I know must
> exist.
>
> I want to write a simple line selection filter that could be used like:
>
> filter < file
>
> I get the following at runtime:
>
> Traceback (most recent call last):
>   File "U:\TimeKeeper\mine.py", line 2, in ?
>     for line in sys.stdin:
> IOError: [Errno 9] Bad file descriptor


Hi Jeff,

Ok there might be a problem with Windows; I see:

    http://mail.python.org/pipermail/python-list/2002-May/104962.html

which sounds really similar to the problem you're seeing.

here appears to be a bug in the Windows shell that you may need to work
around.  The most common workaround I see is wrapping the program with a
'cmd' file. So you can do write a "mine.cmd" program with the following
content:

### mine.cmd
@python mine.py %*
###


After which, you should be able to say:

    mine < file

and things should work again.


There's a thread about this issue here:

http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/c5c687b31434a168/e6e6da312e7b18c6#e6e6da312e7b18c6


Best of wishes to you!



More information about the Tutor mailing list