Index: Doc/lib/liboptparse.tex =================================================================== --- Doc/lib/liboptparse.tex (revision 42187) +++ Doc/lib/liboptparse.tex (working copy) @@ -1035,11 +1035,22 @@ OptionValueError if an invalid string is given. -\subsubsection{Querying and manipulating your option parser\label{optparse-querying-manipulating-option-parser}} +\subsubsection{Querying, manipulating and changing the default + behavior of your option parser\label{optparse-querying-manipulating-option-parser}} -Sometimes, it's useful to poke around your option parser and see what's -there. OptionParser provides a couple of methods to help you out: +The default behavior of the option parser can be customized a +little bit. Also, sometimes, it's useful to poke around your option parser +and see what's there. OptionParser provides a few methods to +help you out: \begin{description} +\item[\code{enable{\_}interspersed(opt{\_}args)}] Set up to stop on +the first non-option. Use this is if you have a command processor +which runs another command which has options of its own and you want +to make sure these options don't get confused. For example perhaps +each has a \code{--help} option. +\item[\code{disable{\_}interspersed(opt{\_}args)}] Has the opposite +effect of \code{disable{\_}interspersed(opt{\_}args)} described above. +This is also the default. \item[\code{has{\_}option(opt{\_}str)}] Return true if the OptionParser has an option with option string \code{opt{\_}str} (e.g., \code{"-q"} or \code{"-{}-verbose"}). Index: Lib/optparse.py =================================================================== --- Lib/optparse.py (revision 42187) +++ Lib/optparse.py (working copy) @@ -1173,9 +1173,19 @@ self.usage = usage def enable_interspersed_args(self): + """Set up to not to stop on the first non-option. This is the + default behavior. See also disable_interspersed_args() and the + class documentation description on attribute + allow_interspersed_args.""" self.allow_interspersed_args = True def disable_interspersed_args(self): + """Set up to stop on the first non-option. Use this is if you + have a command processor which runs another command which has + options of its own and you want to make sure these options + don't get confused. For example perhaps each has a --help + option. See also the class documentation in the description on + attribute allow_interspersed_args.""" self.allow_interspersed_args = False def set_process_default_values(self, process):