piping into a python script

Donn donn.ingle at gmail.com
Thu Jan 24 12:03:19 EST 2008


> wget -i -
> it doesn't do anything, just waits for your input. Your applications
> probably should behave the same.
Okay, that works for me.

> Paddy wrote:
> > ls *.a | ./fui.py -f - *.b
> It doesn't seem to me that -f parameter is necessary for your
> application. 
Yes and no, I have another option that needs to take a variable number of 
args.

> It should treat all the arguments as the filenames, 
> shouldn't it? And when one of the filenames is -, just try to read
> stdin.
I have tested getopt and it strips the lone '-' out. I can get it from 
sys.argv, but then I am really doing more parsing than I want to. It's a 
tricky job this. I think I will look in sys.argv, if I find a single dash the 
I will replace that element in the list with whatever comes from stdin. Then 
I'll pass all of it to getopt.

Thanks for the help.
\d


-- 
When you allow legends to rule your life, your world is based on fiction
-- Segio Aragones (Groo the Wanderer Number 99)

Fonty Python and other dev news at:
http://otherwiseingle.blogspot.com/



More information about the Python-list mailing list