* Lane, Frank L <[EMAIL PROTECTED]> [2005-09-08 09:49]:
> Hi List,
>  
> I wanted to take the stdout of a process and redirect it to stdin of a
> python script, then after playing with the input in the script I want to
> send it back to stdout (all of this to be done while the original
> process runs happily along).  I can't seem to figure out the correct
> syntax if this is possible.
>  
> e.g.
>  
> C:\> runner.exe | script.py
> C:\> runner.exe > script.py  # this overwrites your script!:-)

I use fileinput for most of my stdin text processing. It also give me
the flexibility of using it as a pipe OR assigning a wordlist of files
to the script instead.

http://www.python.org/doc/2.4.1/lib/module-fileinput.html

import fileinput
for line in fileinput.input():
    process(line)


-- 
David Rock
[EMAIL PROTECTED]

Attachment: pgp3RtUbUyLUC.pgp
Description: PGP signature

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to