Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / amd64 / html / python / lib / optparse-terminology.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python Documentation Index' />
<link rel="first" href="lib.html" title='Python Library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="next" href="optparse-what-options-for.html" />
<link rel="prev" href="optparse-background.html" />
<link rel="parent" href="optparse-background.html" />
<link rel="next" href="optparse-what-options-for.html" />
<meta name='aesop' content='information' />
<title>6.21.1.1 Terminology</title>
</head>
<body>
<DIV CLASS="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="6.21.1 Background"
href="optparse-background.html"><img src='../icons/previous.png'
border='0' height='32' alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="6.21.1 Background"
href="optparse-background.html"><img src='../icons/up.png'
border='0' height='32' alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="6.21.1.2 What are options"
href="optparse-what-options-for.html"><img src='../icons/next.png'
border='0' height='32' alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
href="contents.html"><img src='../icons/contents.png'
border='0' height='32' alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
border='0' height='32' alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
href="genindex.html"><img src='../icons/index.png'
border='0' height='32' alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="optparse-background.html">6.21.1 Background</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="optparse-background.html">6.21.1 Background</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="optparse-what-options-for.html">6.21.1.2 What are options</A>
</div>
<hr /></div>
</DIV>
<!--End of Navigation Panel-->
<H3><A NAME="SECTION0082111000000000000000"></A><A NAME="optparse-terminology"></A>
<BR>
6.21.1.1 Terminology
</H3>
<DL>
<DT><STRONG>argument</STRONG></DT>
<DD>a string entered on the command-line, and passed by the shell to
<code>execl()</code> or <code>execv()</code>. In Python, arguments are elements of
<code>sys.argv[1:]</code> (<code>sys.argv[0]</code> is the name of the program being
executed). <span class="Unix">Unix</span> shells also use the term ``word''.
<P>
It is occasionally desirable to substitute an argument list other
than <code>sys.argv[1:]</code>, so you should read ``argument'' as ``an element of
<code>sys.argv[1:]</code>, or of some other list provided as a substitute for
<code>sys.argv[1:]</code>''.
</DD>
<DT><STRONG>option </STRONG></DT>
<DD>an argument used to supply extra information to guide or customize the
execution of a program. There are many different syntaxes for
options; the traditional <span class="Unix">Unix</span> syntax is a hyphen (``-'') followed by a
single letter, e.g. <code>"-x"</code> or <code>"-F"</code>. Also, traditional <span class="Unix">Unix</span>
syntax allows multiple options to be merged into a single argument,
e.g. <code>"-x -F"</code> is equivalent to <code>"-xF"</code>. The GNU project
introduced <code>"-"</code> followed by a series of hyphen-separated words,
e.g. <code>"-file"</code> or <code>"-dry-run"</code>. These are the only two option
syntaxes provided by <tt class="module">optparse</tt>.
<P>
Some other option syntaxes that the world has seen include:
<UL>
<LI>
a hyphen followed by a few letters, e.g. <code>"-pf"</code> (this is
<em>not</em> the same as multiple options merged into a single argument)
<P>
</LI>
<LI>
a hyphen followed by a whole word, e.g. <code>"-file"</code> (this is
technically equivalent to the previous syntax, but they aren't
usually seen in the same program)
<P>
</LI>
<LI>
a plus sign followed by a single letter, or a few letters,
or a word, e.g. <code>"+f"</code>, <code>"+rgb"</code>
<P>
</LI>
<LI>
a slash followed by a letter, or a few letters, or a word, e.g.
<code>"/f"</code>, <code>"/file"</code>
<P>
</LI>
</UL>
<P>
These option syntaxes are not supported by <tt class="module">optparse</tt>, and they never will
be. This is deliberate: the first three are non-standard on any
environment, and the last only makes sense if you're exclusively
targeting VMS, MS-DOS, and/or Windows.
</DD>
<DT><STRONG>option argument</STRONG></DT>
<DD>an argument that follows an option, is closely associated with that
option, and is consumed from the argument list when that option is.
With <tt class="module">optparse</tt>, option arguments may either be in a separate argument
from their option:
<div class="verbatim"><pre>
-f foo
--file foo
</pre></div>
<P>
or included in the same argument:
<div class="verbatim"><pre>
-ffoo
--file=foo
</pre></div>
<P>
Typically, a given option either takes an argument or it doesn't.
Lots of people want an ``optional option arguments'' feature, meaning
that some options will take an argument if they see it, and won't if
they don't. This is somewhat controversial, because it makes parsing
ambiguous: if <code>"-a"</code> takes an optional argument and <code>"-b"</code> is
another option entirely, how do we interpret <code>"-ab"</code>? Because of
this ambiguity, <tt class="module">optparse</tt> does not support this feature.
</DD>
<DT><STRONG>positional argument</STRONG></DT>
<DD>something leftover in the argument list after options have been
parsed, i.e. after options and their arguments have been parsed and
removed from the argument list.
</DD>
<DT><STRONG>required option</STRONG></DT>
<DD>an option that must be supplied on the command-line; note that the
phrase ``required option'' is self-contradictory in English. <tt class="module">optparse</tt>
doesn't prevent you from implementing required options, but doesn't
give you much help at it either. See <code>examples/required_1.py</code> and
<code>examples/required_2.py</code> in the <tt class="module">optparse</tt> source distribution for two
ways to implement required options with <tt class="module">optparse</tt>.
</DD>
</DL>
<P>
For example, consider this hypothetical command-line:
<div class="verbatim"><pre>
prog -v --report /tmp/report.txt foo bar
</pre></div>
<P>
<code>"-v"</code> and <code>"-report"</code> are both options. Assuming that
<b class="programopt">--report</b> takes one argument, <code>"/tmp/report.txt"</code> is an option
argument. <code>"foo"</code> and <code>"bar"</code> are positional arguments.
<P>
<DIV CLASS="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="6.21.1 Background"
href="optparse-background.html"><img src='../icons/previous.png'
border='0' height='32' alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="6.21.1 Background"
href="optparse-background.html"><img src='../icons/up.png'
border='0' height='32' alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="6.21.1.2 What are options"
href="optparse-what-options-for.html"><img src='../icons/next.png'
border='0' height='32' alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
href="contents.html"><img src='../icons/contents.png'
border='0' height='32' alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
border='0' height='32' alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
href="genindex.html"><img src='../icons/index.png'
border='0' height='32' alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="optparse-background.html">6.21.1 Background</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="optparse-background.html">6.21.1 Background</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="optparse-what-options-for.html">6.21.1.2 What are options</A>
</div>
</div>
<hr />
<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>