Re: [Tutor] Optparse question: if only certain values are acceptable

2009-05-09 Thread Kent Johnson
On Fri, May 8, 2009 at 9:09 PM, Terry Carroll wrote: > It's exactly what I was looking for.  Thanks very much. > > Now I'm going to have to re-read the docs and see why I couldn't pick that > up from them. You have to read pretty far down, to the sections on Option attributes and Standard Optio

Re: [Tutor] Optparse question: if only certain values are acceptable

2009-05-09 Thread Alan Gauld
"Terry Carroll" wrote The toy summary is that I want to have the following command format: prognam -f FORMAT Where FORMAT, if specified, must be one of "X", "Y", or "Z". In otherwords, if the user enters: progname -f X It runs, producing its output in format X. Similar if "Y" or "Z" is

Re: [Tutor] Optparse question: if only certain values are acceptable

2009-05-08 Thread Terry Carroll
On Sat, 9 May 2009, Sander Sweers wrote: > Is the below what you are looking for? It's exactly what I was looking for. Thanks very much. Now I'm going to have to re-read the docs and see why I couldn't pick that up from them. ___ Tutor maillist -

Re: [Tutor] Optparse question: if only certain values are acceptable

2009-05-08 Thread Sander Sweers
2009/5/9 Terry Carroll : > In otherwords, if the user enters: > >  progname -f X > > It runs, producing its output in format X.  Similar if "Y" or "Z" is > specified instead of "X". > > But if the user specifies > >  progname -f A > > I want it to spit up because A is not a recognized format. Is t

[Tutor] Optparse question: if only certain values are acceptable

2009-05-08 Thread Terry Carroll
I'm tryng to use optparse for the first time. The toy summary is that I want to have the following command format: prognam -f FORMAT Where FORMAT, if specified, must be one of "X", "Y", or "Z". In otherwords, if the user enters: progname -f X It runs, producing its output in format X. Sim

Re: [Tutor] optparse

2008-12-23 Thread Alan Gauld
"Kent Johnson" wrote for filename in os.listdir(directory): result = re.match(s, filename) print result You never open and read the files. You are searching for the pattern in the filename, not in the contents of the file. Also note that match() only searches starting

Re: [Tutor] optparse

2008-12-23 Thread Kent Johnson
On Tue, Dec 23, 2008 at 3:10 PM, Matt Herzog wrote: >for filename in os.listdir(directory): >result = re.match(s, filename) >print result You never open and read the files. You are searching for the pattern in the filename, not in the contents of the file. If there is no

[Tutor] optparse

2008-12-23 Thread Matt Herzog
Hi All. I want to write a script that will emulate grep to some extent. This is just an exercise for me. I want to run the script like this: ./pythongrep directory searchstring Just like grep, I want it to print: filename, instance_of_match As of now, the script can't find anything I tell it t

Re: [Tutor] optparse example

2008-09-22 Thread Don Jennings
On 9/22/08, Tasos Latsas <[EMAIL PROTECTED]> wrote: > Hello list, > I tried the optparse example from the python library reference and it > doesn't seem to work..what am I doing wrong? > I keep getting the "incorrect number of arguments" message although i > use the correct number.. Actually, you

Re: [Tutor] optparse example

2008-09-22 Thread Carlos Hanson
On Mon, Sep 22, 2008 at 7:16 AM, Tasos Latsas <[EMAIL PROTECTED]> wrote: > Hello list, > I tried the optparse example from the python library reference and it > doesn't seem to work..what am I doing wrong? > I keep getting the "incorrect number of arguments" message although i > use the correct num

[Tutor] optparse example

2008-09-22 Thread Tasos Latsas
Hello list, I tried the optparse example from the python library reference and it doesn't seem to work..what am I doing wrong? I keep getting the "incorrect number of arguments" message although i use the correct number.. The example is here : http://docs.python.org/lib/optparse-putting-it-all-tog