Validating Command Line Options

Joe Riopel goon12 at gmail.com
Wed Mar 23 10:39:16 EDT 2011


On Wed, Mar 23, 2011 at 10:10 AM, T <misceverything at gmail.com> 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 would be invalid).  Thanks
> in advance.

It looks like argparse supports mutually exclusive option groups.
http://argparse.googlecode.com/svn/trunk/doc/other-methods.html#add_mutually_exclusive_group



More information about the Python-list mailing list