Re: piping into a python script

2008-02-01 Thread anonymous
I'm not sure I understane the question but my contribution is : import sys names = sys.argv[1:] line = 'x' while line: line = sys.stdin.readline().strip() if line: names.append (line) print "names=", names Called using: ls | stdtest.py arg1 arg2 arg3 Does this help? Andy -- http

Re: piping into a python script

2008-01-25 Thread Donn Ingle
Nick Craig-Wood wrote: > This iterates over the lines of all files listed in sys.argv[1:], > defaulting to sys.stdin if the list is empty. If a filename is '-', it > is also replaced by sys.stdin. To specify an alternative list of > filenames, pass it as the first argument to input(). A single fil

Re: piping into a python script

2008-01-25 Thread Donn Ingle
Hexamorph wrote: > It's a bit clumsy, but seems to do what I guess you want. Hey, thanks for that! I will have a go. \d -- http://mail.python.org/mailman/listinfo/python-list

Re: piping into a python script

2008-01-25 Thread Donn
Andrew, Thanks for your tips. I managed to get a working script going. I am sure there will be stdin 'issues' to come, but I hope not. If anyone wants to have a look, it's on the cheese shop at: http://pypi.python.org/pypi/fui \d -- "You know, I've gone to a lot of psychics, and they've told me

Re: piping into a python script

2008-01-25 Thread Nick Craig-Wood
Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Thu, 24 Jan 2008 17:17:25 +0200, Donn Ingle wrote: > > > Given these two examples: > > 1. > > ./fui.py *.py > > 2. > > ls *.py | ./fui.py > > > > How can I capture a list of the arguments? > > I need to get all the strings (file or dir na

Re: piping into a python script

2008-01-24 Thread Donn
Thanks for the tips, I'll decode and try 'em all out. > Ah yes, Groo. Ever wonder who would win if Groo and Forrest Gump fought > each other? Heh ;) I reckon they'd both die laughing. Be fun to watch -- if anyone else survived! \d -- "A computer without Windows is like chocolate cake without

RE: piping into a python script

2008-01-24 Thread Reedick, Andrew
> -Original Message- > From: [EMAIL PROTECTED] [mailto:python- > [EMAIL PROTECTED] On Behalf Of Donn > Sent: Thursday, January 24, 2008 12:03 PM > To: MichaƂ Bentkowski > Cc: python-list@python.org > Subject: Re: piping into a python script > > I have tested ge

Re: piping into a python script

2008-01-24 Thread Hexamorph
Donn Ingle wrote: > Paddy wrote: >> fileinput is set to process each file a line at a time unfortunately. > Wow. So there seems to be no solution to my OP. I'm amazed, I would have > thought a simple list of strings, one from stdin and one from the args, > would be easy to get. > > I *really* don'

Re: piping into a python script

2008-01-24 Thread Donn
> 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 op

Re: piping into a python script

2008-01-24 Thread Donn Ingle
Paddy wrote: > fileinput is set to process each file a line at a time unfortunately. Wow. So there seems to be no solution to my OP. I'm amazed, I would have thought a simple list of strings, one from stdin and one from the args, would be easy to get. I *really* don't want to open each file, that

Re: piping into a python script

2008-01-24 Thread Paddy
On Jan 24, 4:02 pm, Donn Ingle <[EMAIL PROTECTED]> wrote: > > Try the fileinput module. > > I did give the fileinput module a go, but I can't find much info on it and > the help is ... well, it's python help ;) Try http://effbot.org/librarybook/fileinput.htm > > > in goes to its stdin where it is

Re: piping into a python script

2008-01-24 Thread Donn Ingle
Paddy wrote: > ls *.a | ./fui.py -f - *.b To be sure I grok this: I am seeing the single dash as a placeholder for where all the piped filenames will go, so *.b happens after *.a has been expanded and they all get fed to -f, right? I'm also guessing you mean that I should detect the single dash an

Re: piping into a python script

2008-01-24 Thread Donn Ingle
> Try the fileinput module. I did give the fileinput module a go, but I can't find much info on it and the help is ... well, it's python help ;) > in goes to its stdin where it is processed if it has an argument of - > fileinput works that way Okay, I did think of the dash, but did not know how to

Re: piping into a python script

2008-01-24 Thread Paddy
On Jan 24, 3:25 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Thu, 24 Jan 2008 17:17:25 +0200, Donn Ingle wrote: > > Given these two examples: > > 1. > > ./fui.py *.py > > 2. > > ls *.py | ./fui.py > > > How can I capture a list of the arguments? > > I need to get all the strings (fi

Re: piping into a python script

2008-01-24 Thread Paddy
On Jan 24, 3:17 pm, Donn Ingle <[EMAIL PROTECTED]> wrote: > Hi, > (Gnu/Linux - Python 2.4/5) > Given these two examples: > 1. > ./fui.py *.py > 2. > ls *.py | ./fui.py > > How can I capture a list of the arguments? > I need to get all the strings (file or dir names) passed via the normal > command

Re: piping into a python script

2008-01-24 Thread Marc 'BlackJack' Rintsch
On Thu, 24 Jan 2008 17:17:25 +0200, Donn Ingle wrote: > Given these two examples: > 1. > ./fui.py *.py > 2. > ls *.py | ./fui.py > > How can I capture a list of the arguments? > I need to get all the strings (file or dir names) passed via the normal > command line and any that may come from a pi