Re: Reading from stdin (in windows)

2008-10-14 Thread Rob Williscroft
[EMAIL PROTECTED] wrote in news:mailman.2448.1223974725.3487.python-
[EMAIL PROTECTED] 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 = sys.stdin.read(1)
  if t == '':
  break
  l.append(t)
 
 t = .join(l)
 ...
 
 and use code this:
 process.py 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 process.py 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 process.py test.txt

Rob.
-- 
http://www.victim-prime.dsl.pipex.com/
--
http://mail.python.org/mailman/listinfo/python-list


Reading from stdin (in windows)

2008-10-14 Thread [EMAIL PROTECTED]

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 = sys.stdin.read(1)
if t == '':
break
l.append(t)

t = .join(l)
...

and use code this:
process.py 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?

Thanks for your help:
   dd

--
http://mail.python.org/mailman/listinfo/python-list