Re: Validating Command Line Options

2011-03-23 Thread Jonathan Gossage
See inline comments On Wed, Mar 23, 2011 at 2:13 PM, Alex Willmer wrote: > On Mar 23, 3:20 pm, T wrote: > > Thanks! argparse is definitely what I need..unfortunately I'm running > > 2.6 now, so I'll need to upgrade to 2.7 and hope that none of my other > > scripts break. > > Argparse was a thi

Re: Validating Command Line Options

2011-03-23 Thread Alex Willmer
On Mar 23, 3:20 pm, T wrote: > Thanks!  argparse is definitely what I need..unfortunately I'm running > 2.6 now, so I'll need to upgrade to 2.7 and hope that none of my other > scripts break. Argparse was a third-party module before it became part of the std- lib. You may find it easier to use th

Re: Validating Command Line Options

2011-03-23 Thread T
Thanks! argparse is definitely what I need..unfortunately I'm running 2.6 now, so I'll need to upgrade to 2.7 and hope that none of my other scripts break. -- http://mail.python.org/mailman/listinfo/python-list

Re: Validating Command Line Options

2011-03-23 Thread Boris FELD
If you're using argparse, you have a method for that named "add_mutually_exclusive_group". Tutorial : http://www.doughellmann.com/PyMOTW/argparse/#mutually-exclusive-options Cheers, Feld Boris 2011/3/23 T : > For a Python script with multiple command line options, what is the > best way to go abo

Re: Validating Command Line Options

2011-03-23 Thread Joe Riopel
On Wed, Mar 23, 2011 at 10:10 AM, T wrote: > For a Python script with multiple command line options, what is the > best way to go about validating that only certain options are used > together?  For example, say -s, -t, and -v are all valid options, but > should never be used together (i.e. -s -t

Re: Validating Command Line Options

2011-03-23 Thread bruce bushby
optparse? http://docs.python.org/library/optparse.html if options.a and options.b: parser.error("options -a and -b are mutually exclusive") On Wed, Mar 23, 2011 at 2:10 PM, T wrote: > For a Python script with multiple command line options, what is the > best way to go about validating th

Validating Command Line Options

2011-03-23 Thread T
For a Python script with multiple command line options, what is the best way to go about validating that only certain options are used together? For example, say -s, -t, and -v are all valid options, but should never be used together (i.e. -s -t would be invalid). Thanks in advance. -- http://ma