Use TeX quotes -- ``foo'' -- as appropriate.

Remove whitespace around em-dashes.
This commit is contained in:
Greg Ward 2003-05-03 19:41:45 +00:00
parent b4e3319302
commit bf8f1b55a8

View file

@ -33,7 +33,7 @@ parser.add_option("-q", "--quiet",
\end{verbatim} \end{verbatim}
With these few lines of code, users of your script can now do the With these few lines of code, users of your script can now do the
"usual thing" on the command-line: ``usual thing'' on the command-line:
\begin{verbatim} \begin{verbatim}
$ <yourscript> -f outfile --quiet $ <yourscript> -f outfile --quiet
@ -281,7 +281,7 @@ strings. In this document, we'll only cover four of the things you
can put there: \var{action}, \var{type}, \var{dest} (destination), and can put there: \var{action}, \var{type}, \var{dest} (destination), and
\var{help}. \var{help}.
\subsubsection{The "store" action\label{optparse-store-action}} \subsubsection{The \var{store} action\label{optparse-store-action}}
The action tells \module{optparse} what to do when it sees one of the The action tells \module{optparse} what to do when it sees one of the
option strings for this option on the command-line. For example, the option strings for this option on the command-line. For example, the
@ -289,7 +289,7 @@ action \var{store} means: take the next argument (or the remainder of
the current argument), ensure that it is of the correct type, and the current argument), ensure that it is of the correct type, and
store it to your chosen destination. store it to your chosen destination.
For example, let's fill in the "..." of that last option: For example, let's fill in the ``...'' of that last option:
\begin{verbatim} \begin{verbatim}
parser.add_option("-f", "--file", parser.add_option("-f", "--file",
@ -308,7 +308,7 @@ args = ["-f", "foo.txt"]
\function{parse_args()}, it automatically uses \var{sys.argv[1:]}.) \function{parse_args()}, it automatically uses \var{sys.argv[1:]}.)
When \module{optparse} sees the \programopt{-f}, it sucks in the next When \module{optparse} sees the \programopt{-f}, it sucks in the next
argument --- ``foo.txt'' --- and stores it in the \var{filename} argument---\code{foo.txt}---and stores it in the \var{filename}
attribute of a special object. That object is the first return value attribute of a special object. That object is the first return value
from \function{parse_args()}, so: from \function{parse_args()}, so:
@ -316,10 +316,10 @@ from \function{parse_args()}, so:
print options.filename print options.filename
\end{verbatim} \end{verbatim}
will print ``foo.txt''. will print \code{foo.txt}.
Other option types supported by \module{optparse} are ``int'' and Other option types supported by \module{optparse} are \code{int} and
``float''. Here's an option that expects an integer argument: \code{float}. Here's an option that expects an integer argument:
\begin{verbatim} \begin{verbatim}
parser.add_option("-n", type="int", dest="num") parser.add_option("-n", type="int", dest="num")
@ -359,7 +359,7 @@ destination for \programopt{-f} is \var{f}.
Adding types is fairly easy; please refer to Adding types is fairly easy; please refer to
section~\ref{optparse-adding-types}, ``Adding new types.'' section~\ref{optparse-adding-types}, ``Adding new types.''
\subsubsection{Other "store_*" actions\label{optparse-other-store-actions}} \subsubsection{Other \var{store_*} actions\label{optparse-other-store-actions}}
Flag options---set a variable to true or false when a particular Flag options---set a variable to true or false when a particular
option is seen---are quite common. \module{optparse} supports them option is seen---are quite common. \module{optparse} supports them
@ -474,12 +474,12 @@ best possible help message:
usage = "usage: %prog [options] arg1 arg2" usage = "usage: %prog [options] arg1 arg2"
\end{verbatim} \end{verbatim}
\module{optparse} expands "\%prog" in the usage string to the name of the \module{optparse} expands \samp{\%prog} in the usage string to the name of the
current script, ie. \code{os.path.basename(sys.argv[0])}. The current script, ie. \code{os.path.basename(sys.argv[0])}. The
expanded string is then printed before the detailed option help. expanded string is then printed before the detailed option help.
If you don't supply a usage string, \module{optparse} uses a bland but If you don't supply a usage string, \module{optparse} uses a bland but
sensible default: ``usage: \%prog [options]'', which is fine if your sensible default: \code{"usage: \%prog [options]"}, which is fine if your
script doesn't take any positional arguments. script doesn't take any positional arguments.
\item every option defines a help string, and doesn't worry about \item every option defines a help string, and doesn't worry about
@ -1363,7 +1363,7 @@ parser.add_option("--foo",
action="callback", callback=check_moon, dest="foo") action="callback", callback=check_moon, dest="foo")
\end{verbatim} \end{verbatim}
(The definition of is_full_moon() is left as an exercise for the (The definition of \code{is_full_moon()} is left as an exercise for the
reader.) reader.)
\strong{Fixed arguments} \strong{Fixed arguments}
@ -1567,20 +1567,20 @@ Adding new actions is a bit trickier, because you have to understand
that \module{optparse} has a couple of classifications for actions: that \module{optparse} has a couple of classifications for actions:
\begin{definitions} \begin{definitions}
\term{"store" actions} \term{``store'' actions}
actions that result in \module{optparse} storing a value to an attribute actions that result in \module{optparse} storing a value to an attribute
of the OptionValues instance; these options require a 'dest' of the OptionValues instance; these options require a \var{dest}
attribute to be supplied to the Option constructor attribute to be supplied to the Option constructor
\term{"typed" actions} \term{``typed'' actions}
actions that take a value from the command line and expect it to be actions that take a value from the command line and expect it to be
of a certain type; or rather, a string that can be converted to a of a certain type; or rather, a string that can be converted to a
certain type. These options require a 'type' attribute to the certain type. These options require a \var{type} attribute to the
Option constructor. Option constructor.
\end{definitions} \end{definitions}
Some default ``store'' actions are ``store'', ``store_const'', Some default ``store'' actions are \var{store}, \var{store_const},
``append'', and ``count''. The default ``typed'' actions are \var{append}, and \var{count}. The default ``typed'' actions are
``store'', ``append'', and ``callback''. \var{store}, \var{append}, and \var{callback}.
When you add an action, you need to decide if it's a ``store'' action, When you add an action, you need to decide if it's a ``store'' action,
a ``typed'', neither, or both. Three class attributes of a ``typed'', neither, or both. Three class attributes of
@ -1590,10 +1590,10 @@ a ``typed'', neither, or both. Three class attributes of
All actions must be listed as strings in ACTIONS. All actions must be listed as strings in ACTIONS.
\end{memberdesc} \end{memberdesc}
\begin{memberdesc}{STORE_ACTIONS} \begin{memberdesc}{STORE_ACTIONS}
"store" actions are additionally listed here. ``store'' actions are additionally listed here.
\end{memberdesc} \end{memberdesc}
\begin{memberdesc}{TYPED_ACTIONS} \begin{memberdesc}{TYPED_ACTIONS}
"typed" actions are additionally listed here. ``typed'' actions are additionally listed here.
\end{memberdesc} \end{memberdesc}
In order to actually implement your new action, you must override In order to actually implement your new action, you must override
@ -1689,7 +1689,7 @@ You'll have to
\begin{enumerate} \begin{enumerate}
\item subclass OptionParser and override the error() method \item subclass OptionParser and override the error() method
\item subclass Option and override the take_action() method---you'll \item subclass Option and override the take_action() method---you'll
need to provide your own handling of the "help" action that need to provide your own handling of the ``help'' action that
doesn't call sys.exit() doesn't call sys.exit()
\end{enumerate} \end{enumerate}