Re: stdin or optional fileinput

2006-03-15 Thread Peter Otten
the.theorist wrote: > I'll keep both those in mind for future programs. > my current fix has been > > if not args: > args = [ sys.stdin ] > else: > map( open, args ) > > and then a modification to the main loop, as you proposed. > > I thought that one day I might run into a problem open

Re: stdin or optional fileinput

2006-03-15 Thread Fredrik Lundh
"the.theorist" wrote: > I used this bit of code to detect wether i want stdinput or not. > > if len(args)==0: > args = [ sys.stdin ] > > Now in my main loop I've written: > > for file in args: > for line in open( file ): > #do stuff > > The probelm occurs when I pass no arguments a

Re: stdin or optional fileinput

2006-03-15 Thread Steve Holden
the.theorist wrote: > Steven Bethard wrote: > >>the.theorist wrote: >> >>>I was writing a small script the other day with the following CLI >>>prog [options] [file]* >>> >>>I've used getopt to parse out the possible options, so we'll ignore >>>that part, and assume for the rest of the discussion t

Re: stdin or optional fileinput

2006-03-15 Thread the.theorist
Steven Bethard wrote: > the.theorist wrote: > > I was writing a small script the other day with the following CLI > > prog [options] [file]* > > > > I've used getopt to parse out the possible options, so we'll ignore > > that part, and assume for the rest of the discussion that args is a > > list

Re: stdin or optional fileinput

2006-03-15 Thread Steven Bethard
the.theorist wrote: > I was writing a small script the other day with the following CLI > prog [options] [file]* > > I've used getopt to parse out the possible options, so we'll ignore > that part, and assume for the rest of the discussion that args is a > list of file names (if any provided). >

stdin or optional fileinput

2006-03-15 Thread the.theorist
I was writing a small script the other day with the following CLI prog [options] [file]* I've used getopt to parse out the possible options, so we'll ignore that part, and assume for the rest of the discussion that args is a list of file names (if any provided). I used this bit of code to detect