~dkuhlman/python-training-materials/Materials

« back to all changes in this revision

Viewing changes to python-2.7.12-docs-html/library/cmd.html

  • Committer: Dave Kuhlman
  • Date: 2017-04-15 16:24:56 UTC
  • Revision ID: dkuhlman@davekuhlman.org-20170415162456-iav9vozzg4iwqwv3
Updated docs

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 
2
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
3
 
 
4
 
 
5
<html xmlns="http://www.w3.org/1999/xhtml">
 
6
  <head>
 
7
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 
8
    
 
9
    <title>23.1. cmd — Support for line-oriented command interpreters &mdash; Python 2.7.12 documentation</title>
 
10
    
 
11
    <link rel="stylesheet" href="../_static/classic.css" type="text/css" />
 
12
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
 
13
    
 
14
    <script type="text/javascript">
 
15
      var DOCUMENTATION_OPTIONS = {
 
16
        URL_ROOT:    '../',
 
17
        VERSION:     '2.7.12',
 
18
        COLLAPSE_INDEX: false,
 
19
        FILE_SUFFIX: '.html',
 
20
        HAS_SOURCE:  true
 
21
      };
 
22
    </script>
 
23
    <script type="text/javascript" src="../_static/jquery.js"></script>
 
24
    <script type="text/javascript" src="../_static/underscore.js"></script>
 
25
    <script type="text/javascript" src="../_static/doctools.js"></script>
 
26
    <script type="text/javascript" src="../_static/sidebar.js"></script>
 
27
    <link rel="search" type="application/opensearchdescription+xml"
 
28
          title="Search within Python 2.7.12 documentation"
 
29
          href="../_static/opensearch.xml"/>
 
30
    <link rel="author" title="About these documents" href="../about.html" />
 
31
    <link rel="copyright" title="Copyright" href="../copyright.html" />
 
32
    <link rel="top" title="Python 2.7.12 documentation" href="../contents.html" />
 
33
    <link rel="up" title="23. Program Frameworks" href="frameworks.html" />
 
34
    <link rel="next" title="23.2. shlex — Simple lexical analysis" href="shlex.html" />
 
35
    <link rel="prev" title="23. Program Frameworks" href="frameworks.html" />
 
36
    <link rel="shortcut icon" type="image/png" href="../_static/py.png" />
 
37
    <script type="text/javascript" src="../_static/copybutton.js"></script>
 
38
    <script type="text/javascript" src="../_static/version_switch.js"></script>
 
39
 
 
40
    
 
41
 
 
42
  </head>
 
43
  <body role="document">  
 
44
    <div class="related" role="navigation" aria-label="related navigation">
 
45
      <h3>Navigation</h3>
 
46
      <ul>
 
47
        <li class="right" style="margin-right: 10px">
 
48
          <a href="../genindex.html" title="General Index"
 
49
             accesskey="I">index</a></li>
 
50
        <li class="right" >
 
51
          <a href="../py-modindex.html" title="Python Module Index"
 
52
             >modules</a> |</li>
 
53
        <li class="right" >
 
54
          <a href="shlex.html" title="23.2. shlex — Simple lexical analysis"
 
55
             accesskey="N">next</a> |</li>
 
56
        <li class="right" >
 
57
          <a href="frameworks.html" title="23. Program Frameworks"
 
58
             accesskey="P">previous</a> |</li>
 
59
        <li><img src="../_static/py.png" alt=""
 
60
                 style="vertical-align: middle; margin-top: -1px"/></li>
 
61
        <li><a href="https://www.python.org/">Python</a> &raquo;</li>
 
62
        <li>
 
63
          <span class="version_switcher_placeholder">2.7.12</span>
 
64
          <a href="../index.html">Documentation</a> &raquo;
 
65
        </li>
 
66
 
 
67
          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &raquo;</li>
 
68
          <li class="nav-item nav-item-2"><a href="frameworks.html" accesskey="U">23. Program Frameworks</a> &raquo;</li> 
 
69
      </ul>
 
70
    </div>    
 
71
 
 
72
    <div class="document">
 
73
      <div class="documentwrapper">
 
74
        <div class="bodywrapper">
 
75
          <div class="body" role="main">
 
76
            
 
77
  <div class="section" id="module-cmd">
 
78
<span id="cmd-support-for-line-oriented-command-interpreters"></span><h1>23.1. <a class="reference internal" href="#module-cmd" title="cmd: Build line-oriented command interpreters."><code class="xref py py-mod docutils literal"><span class="pre">cmd</span></code></a> &#8212; Support for line-oriented command interpreters<a class="headerlink" href="#module-cmd" title="Permalink to this headline">¶</a></h1>
 
79
<p><strong>Source code:</strong> <a class="reference external" href="https://hg.python.org/cpython/file/2.7/Lib/cmd.py">Lib/cmd.py</a></p>
 
80
<hr class="docutils" />
 
81
<p>The <a class="reference internal" href="#cmd.Cmd" title="cmd.Cmd"><code class="xref py py-class docutils literal"><span class="pre">Cmd</span></code></a> class provides a simple framework for writing line-oriented
 
82
command interpreters.  These are often useful for test harnesses, administrative
 
83
tools, and prototypes that will later be wrapped in a more sophisticated
 
84
interface.</p>
 
85
<dl class="class">
 
86
<dt id="cmd.Cmd">
 
87
<em class="property">class </em><code class="descclassname">cmd.</code><code class="descname">Cmd</code><span class="sig-paren">(</span><span class="optional">[</span><em>completekey</em><span class="optional">[</span>, <em>stdin</em><span class="optional">[</span>, <em>stdout</em><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#cmd.Cmd" title="Permalink to this definition">¶</a></dt>
 
88
<dd><p>A <a class="reference internal" href="#cmd.Cmd" title="cmd.Cmd"><code class="xref py py-class docutils literal"><span class="pre">Cmd</span></code></a> instance or subclass instance is a line-oriented interpreter
 
89
framework.  There is no good reason to instantiate <a class="reference internal" href="#cmd.Cmd" title="cmd.Cmd"><code class="xref py py-class docutils literal"><span class="pre">Cmd</span></code></a> itself; rather,
 
90
it&#8217;s useful as a superclass of an interpreter class you define yourself in order
 
91
to inherit <a class="reference internal" href="#cmd.Cmd" title="cmd.Cmd"><code class="xref py py-class docutils literal"><span class="pre">Cmd</span></code></a>&#8216;s methods and encapsulate action methods.</p>
 
92
<p>The optional argument <em>completekey</em> is the <a class="reference internal" href="readline.html#module-readline" title="readline: GNU readline support for Python. (Unix)"><code class="xref py py-mod docutils literal"><span class="pre">readline</span></code></a> name of a completion
 
93
key; it defaults to <code class="kbd docutils literal"><span class="pre">Tab</span></code>. If <em>completekey</em> is not <a class="reference internal" href="constants.html#None" title="None"><code class="xref py py-const docutils literal"><span class="pre">None</span></code></a> and
 
94
<a class="reference internal" href="readline.html#module-readline" title="readline: GNU readline support for Python. (Unix)"><code class="xref py py-mod docutils literal"><span class="pre">readline</span></code></a> is available, command completion is done automatically.</p>
 
95
<p>The optional arguments <em>stdin</em> and <em>stdout</em> specify the  input and output file
 
96
objects that the Cmd instance or subclass  instance will use for input and
 
97
output. If not specified, they will default to <a class="reference internal" href="sys.html#sys.stdin" title="sys.stdin"><code class="xref py py-data docutils literal"><span class="pre">sys.stdin</span></code></a> and
 
98
<a class="reference internal" href="sys.html#sys.stdout" title="sys.stdout"><code class="xref py py-data docutils literal"><span class="pre">sys.stdout</span></code></a>.</p>
 
99
<p>If you want a given <em>stdin</em> to be used, make sure to set the instance&#8217;s
 
100
<a class="reference internal" href="#cmd.Cmd.use_rawinput" title="cmd.Cmd.use_rawinput"><code class="xref py py-attr docutils literal"><span class="pre">use_rawinput</span></code></a> attribute to <code class="docutils literal"><span class="pre">False</span></code>, otherwise <em>stdin</em> will be
 
101
ignored.</p>
 
102
<div class="versionchanged">
 
103
<p><span class="versionmodified">Changed in version 2.3: </span>The <em>stdin</em> and <em>stdout</em> parameters were added.</p>
 
104
</div>
 
105
</dd></dl>
 
106
 
 
107
<div class="section" id="cmd-objects">
 
108
<span id="id1"></span><h2>23.1.1. Cmd Objects<a class="headerlink" href="#cmd-objects" title="Permalink to this headline">¶</a></h2>
 
109
<p>A <a class="reference internal" href="#cmd.Cmd" title="cmd.Cmd"><code class="xref py py-class docutils literal"><span class="pre">Cmd</span></code></a> instance has the following methods:</p>
 
110
<dl class="method">
 
111
<dt id="cmd.Cmd.cmdloop">
 
112
<code class="descclassname">Cmd.</code><code class="descname">cmdloop</code><span class="sig-paren">(</span><span class="optional">[</span><em>intro</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#cmd.Cmd.cmdloop" title="Permalink to this definition">¶</a></dt>
 
113
<dd><p>Repeatedly issue a prompt, accept input, parse an initial prefix off the
 
114
received input, and dispatch to action methods, passing them the remainder of
 
115
the line as argument.</p>
 
116
<p>The optional argument is a banner or intro string to be issued before the first
 
117
prompt (this overrides the <a class="reference internal" href="#cmd.Cmd.intro" title="cmd.Cmd.intro"><code class="xref py py-attr docutils literal"><span class="pre">intro</span></code></a> class attribute).</p>
 
118
<p>If the <a class="reference internal" href="readline.html#module-readline" title="readline: GNU readline support for Python. (Unix)"><code class="xref py py-mod docutils literal"><span class="pre">readline</span></code></a> module is loaded, input will automatically inherit
 
119
<strong class="program">bash</strong>-like history-list editing (e.g. <code class="kbd docutils literal"><span class="pre">Control-P</span></code> scrolls back
 
120
to the last command, <code class="kbd docutils literal"><span class="pre">Control-N</span></code> forward to the next one, <code class="kbd docutils literal"><span class="pre">Control-F</span></code>
 
121
moves the cursor to the right non-destructively, <code class="kbd docutils literal"><span class="pre">Control-B</span></code> moves the
 
122
cursor to the left non-destructively, etc.).</p>
 
123
<p>An end-of-file on input is passed back as the string <code class="docutils literal"><span class="pre">'EOF'</span></code>.</p>
 
124
<p>An interpreter instance will recognize a command name <code class="docutils literal"><span class="pre">foo</span></code> if and only if it
 
125
has a method <code class="xref py py-meth docutils literal"><span class="pre">do_foo()</span></code>.  As a special case, a line beginning with the
 
126
character <code class="docutils literal"><span class="pre">'?'</span></code> is dispatched to the method <code class="xref py py-meth docutils literal"><span class="pre">do_help()</span></code>.  As another
 
127
special case, a line beginning with the character <code class="docutils literal"><span class="pre">'!'</span></code> is dispatched to the
 
128
method <code class="xref py py-meth docutils literal"><span class="pre">do_shell()</span></code> (if such a method is defined).</p>
 
129
<p>This method will return when the <a class="reference internal" href="#cmd.Cmd.postcmd" title="cmd.Cmd.postcmd"><code class="xref py py-meth docutils literal"><span class="pre">postcmd()</span></code></a> method returns a true value.
 
130
The <em>stop</em> argument to <a class="reference internal" href="#cmd.Cmd.postcmd" title="cmd.Cmd.postcmd"><code class="xref py py-meth docutils literal"><span class="pre">postcmd()</span></code></a> is the return value from the command&#8217;s
 
131
corresponding <code class="xref py py-meth docutils literal"><span class="pre">do_*()</span></code> method.</p>
 
132
<p>If completion is enabled, completing commands will be done automatically, and
 
133
completing of commands args is done by calling <code class="xref py py-meth docutils literal"><span class="pre">complete_foo()</span></code> with
 
134
arguments <em>text</em>, <em>line</em>, <em>begidx</em>, and <em>endidx</em>.  <em>text</em> is the string prefix
 
135
we are attempting to match: all returned matches must begin with it. <em>line</em> is
 
136
the current input line with leading whitespace removed, <em>begidx</em> and <em>endidx</em>
 
137
are the beginning and ending indexes of the prefix text, which could be used to
 
138
provide different completion depending upon which position the argument is in.</p>
 
139
<p>All subclasses of <a class="reference internal" href="#cmd.Cmd" title="cmd.Cmd"><code class="xref py py-class docutils literal"><span class="pre">Cmd</span></code></a> inherit a predefined <code class="xref py py-meth docutils literal"><span class="pre">do_help()</span></code>.  This
 
140
method, called with an argument <code class="docutils literal"><span class="pre">'bar'</span></code>, invokes the corresponding method
 
141
<code class="xref py py-meth docutils literal"><span class="pre">help_bar()</span></code>, and if that is not present, prints the docstring of
 
142
<code class="xref py py-meth docutils literal"><span class="pre">do_bar()</span></code>, if available.  With no argument, <code class="xref py py-meth docutils literal"><span class="pre">do_help()</span></code> lists all
 
143
available help topics (that is, all commands with corresponding
 
144
<code class="xref py py-meth docutils literal"><span class="pre">help_*()</span></code> methods or commands that have docstrings), and also lists any
 
145
undocumented commands.</p>
 
146
</dd></dl>
 
147
 
 
148
<dl class="method">
 
149
<dt id="cmd.Cmd.onecmd">
 
150
<code class="descclassname">Cmd.</code><code class="descname">onecmd</code><span class="sig-paren">(</span><em>str</em><span class="sig-paren">)</span><a class="headerlink" href="#cmd.Cmd.onecmd" title="Permalink to this definition">¶</a></dt>
 
151
<dd><p>Interpret the argument as though it had been typed in response to the prompt.
 
152
This may be overridden, but should not normally need to be; see the
 
153
<a class="reference internal" href="#cmd.Cmd.precmd" title="cmd.Cmd.precmd"><code class="xref py py-meth docutils literal"><span class="pre">precmd()</span></code></a> and <a class="reference internal" href="#cmd.Cmd.postcmd" title="cmd.Cmd.postcmd"><code class="xref py py-meth docutils literal"><span class="pre">postcmd()</span></code></a> methods for useful execution hooks.  The
 
154
return value is a flag indicating whether interpretation of commands by the
 
155
interpreter should stop.  If there is a <code class="xref py py-meth docutils literal"><span class="pre">do_*()</span></code> method for the command
 
156
<em>str</em>, the return value of that method is returned, otherwise the return value
 
157
from the <a class="reference internal" href="#cmd.Cmd.default" title="cmd.Cmd.default"><code class="xref py py-meth docutils literal"><span class="pre">default()</span></code></a> method is returned.</p>
 
158
</dd></dl>
 
159
 
 
160
<dl class="method">
 
161
<dt id="cmd.Cmd.emptyline">
 
162
<code class="descclassname">Cmd.</code><code class="descname">emptyline</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#cmd.Cmd.emptyline" title="Permalink to this definition">¶</a></dt>
 
163
<dd><p>Method called when an empty line is entered in response to the prompt. If this
 
164
method is not overridden, it repeats the last nonempty command entered.</p>
 
165
</dd></dl>
 
166
 
 
167
<dl class="method">
 
168
<dt id="cmd.Cmd.default">
 
169
<code class="descclassname">Cmd.</code><code class="descname">default</code><span class="sig-paren">(</span><em>line</em><span class="sig-paren">)</span><a class="headerlink" href="#cmd.Cmd.default" title="Permalink to this definition">¶</a></dt>
 
170
<dd><p>Method called on an input line when the command prefix is not recognized. If
 
171
this method is not overridden, it prints an error message and returns.</p>
 
172
</dd></dl>
 
173
 
 
174
<dl class="method">
 
175
<dt id="cmd.Cmd.completedefault">
 
176
<code class="descclassname">Cmd.</code><code class="descname">completedefault</code><span class="sig-paren">(</span><em>text</em>, <em>line</em>, <em>begidx</em>, <em>endidx</em><span class="sig-paren">)</span><a class="headerlink" href="#cmd.Cmd.completedefault" title="Permalink to this definition">¶</a></dt>
 
177
<dd><p>Method called to complete an input line when no command-specific
 
178
<code class="xref py py-meth docutils literal"><span class="pre">complete_*()</span></code> method is available.  By default, it returns an empty list.</p>
 
179
</dd></dl>
 
180
 
 
181
<dl class="method">
 
182
<dt id="cmd.Cmd.precmd">
 
183
<code class="descclassname">Cmd.</code><code class="descname">precmd</code><span class="sig-paren">(</span><em>line</em><span class="sig-paren">)</span><a class="headerlink" href="#cmd.Cmd.precmd" title="Permalink to this definition">¶</a></dt>
 
184
<dd><p>Hook method executed just before the command line <em>line</em> is interpreted, but
 
185
after the input prompt is generated and issued.  This method is a stub in
 
186
<a class="reference internal" href="#cmd.Cmd" title="cmd.Cmd"><code class="xref py py-class docutils literal"><span class="pre">Cmd</span></code></a>; it exists to be overridden by subclasses.  The return value is
 
187
used as the command which will be executed by the <a class="reference internal" href="#cmd.Cmd.onecmd" title="cmd.Cmd.onecmd"><code class="xref py py-meth docutils literal"><span class="pre">onecmd()</span></code></a> method; the
 
188
<a class="reference internal" href="#cmd.Cmd.precmd" title="cmd.Cmd.precmd"><code class="xref py py-meth docutils literal"><span class="pre">precmd()</span></code></a> implementation may re-write the command or simply return <em>line</em>
 
189
unchanged.</p>
 
190
</dd></dl>
 
191
 
 
192
<dl class="method">
 
193
<dt id="cmd.Cmd.postcmd">
 
194
<code class="descclassname">Cmd.</code><code class="descname">postcmd</code><span class="sig-paren">(</span><em>stop</em>, <em>line</em><span class="sig-paren">)</span><a class="headerlink" href="#cmd.Cmd.postcmd" title="Permalink to this definition">¶</a></dt>
 
195
<dd><p>Hook method executed just after a command dispatch is finished.  This method is
 
196
a stub in <a class="reference internal" href="#cmd.Cmd" title="cmd.Cmd"><code class="xref py py-class docutils literal"><span class="pre">Cmd</span></code></a>; it exists to be overridden by subclasses.  <em>line</em> is the
 
197
command line which was executed, and <em>stop</em> is a flag which indicates whether
 
198
execution will be terminated after the call to <a class="reference internal" href="#cmd.Cmd.postcmd" title="cmd.Cmd.postcmd"><code class="xref py py-meth docutils literal"><span class="pre">postcmd()</span></code></a>; this will be the
 
199
return value of the <a class="reference internal" href="#cmd.Cmd.onecmd" title="cmd.Cmd.onecmd"><code class="xref py py-meth docutils literal"><span class="pre">onecmd()</span></code></a> method.  The return value of this method will
 
200
be used as the new value for the internal flag which corresponds to <em>stop</em>;
 
201
returning false will cause interpretation to continue.</p>
 
202
</dd></dl>
 
203
 
 
204
<dl class="method">
 
205
<dt id="cmd.Cmd.preloop">
 
206
<code class="descclassname">Cmd.</code><code class="descname">preloop</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#cmd.Cmd.preloop" title="Permalink to this definition">¶</a></dt>
 
207
<dd><p>Hook method executed once when <a class="reference internal" href="#cmd.Cmd.cmdloop" title="cmd.Cmd.cmdloop"><code class="xref py py-meth docutils literal"><span class="pre">cmdloop()</span></code></a> is called.  This method is a stub
 
208
in <a class="reference internal" href="#cmd.Cmd" title="cmd.Cmd"><code class="xref py py-class docutils literal"><span class="pre">Cmd</span></code></a>; it exists to be overridden by subclasses.</p>
 
209
</dd></dl>
 
210
 
 
211
<dl class="method">
 
212
<dt id="cmd.Cmd.postloop">
 
213
<code class="descclassname">Cmd.</code><code class="descname">postloop</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#cmd.Cmd.postloop" title="Permalink to this definition">¶</a></dt>
 
214
<dd><p>Hook method executed once when <a class="reference internal" href="#cmd.Cmd.cmdloop" title="cmd.Cmd.cmdloop"><code class="xref py py-meth docutils literal"><span class="pre">cmdloop()</span></code></a> is about to return. This method
 
215
is a stub in <a class="reference internal" href="#cmd.Cmd" title="cmd.Cmd"><code class="xref py py-class docutils literal"><span class="pre">Cmd</span></code></a>; it exists to be overridden by subclasses.</p>
 
216
</dd></dl>
 
217
 
 
218
<p>Instances of <a class="reference internal" href="#cmd.Cmd" title="cmd.Cmd"><code class="xref py py-class docutils literal"><span class="pre">Cmd</span></code></a> subclasses have some public instance variables:</p>
 
219
<dl class="attribute">
 
220
<dt id="cmd.Cmd.prompt">
 
221
<code class="descclassname">Cmd.</code><code class="descname">prompt</code><a class="headerlink" href="#cmd.Cmd.prompt" title="Permalink to this definition">¶</a></dt>
 
222
<dd><p>The prompt issued to solicit input.</p>
 
223
</dd></dl>
 
224
 
 
225
<dl class="attribute">
 
226
<dt id="cmd.Cmd.identchars">
 
227
<code class="descclassname">Cmd.</code><code class="descname">identchars</code><a class="headerlink" href="#cmd.Cmd.identchars" title="Permalink to this definition">¶</a></dt>
 
228
<dd><p>The string of characters accepted for the command prefix.</p>
 
229
</dd></dl>
 
230
 
 
231
<dl class="attribute">
 
232
<dt id="cmd.Cmd.lastcmd">
 
233
<code class="descclassname">Cmd.</code><code class="descname">lastcmd</code><a class="headerlink" href="#cmd.Cmd.lastcmd" title="Permalink to this definition">¶</a></dt>
 
234
<dd><p>The last nonempty command prefix seen.</p>
 
235
</dd></dl>
 
236
 
 
237
<dl class="attribute">
 
238
<dt id="cmd.Cmd.cmdqueue">
 
239
<code class="descclassname">Cmd.</code><code class="descname">cmdqueue</code><a class="headerlink" href="#cmd.Cmd.cmdqueue" title="Permalink to this definition">¶</a></dt>
 
240
<dd><p>A list of queued input lines.  The cmdqueue list is checked in
 
241
<a class="reference internal" href="#cmd.Cmd.cmdloop" title="cmd.Cmd.cmdloop"><code class="xref py py-meth docutils literal"><span class="pre">cmdloop()</span></code></a> when new input is needed; if it is nonempty, its elements
 
242
will be processed in order, as if entered at the prompt.</p>
 
243
</dd></dl>
 
244
 
 
245
<dl class="attribute">
 
246
<dt id="cmd.Cmd.intro">
 
247
<code class="descclassname">Cmd.</code><code class="descname">intro</code><a class="headerlink" href="#cmd.Cmd.intro" title="Permalink to this definition">¶</a></dt>
 
248
<dd><p>A string to issue as an intro or banner.  May be overridden by giving the
 
249
<a class="reference internal" href="#cmd.Cmd.cmdloop" title="cmd.Cmd.cmdloop"><code class="xref py py-meth docutils literal"><span class="pre">cmdloop()</span></code></a> method an argument.</p>
 
250
</dd></dl>
 
251
 
 
252
<dl class="attribute">
 
253
<dt id="cmd.Cmd.doc_header">
 
254
<code class="descclassname">Cmd.</code><code class="descname">doc_header</code><a class="headerlink" href="#cmd.Cmd.doc_header" title="Permalink to this definition">¶</a></dt>
 
255
<dd><p>The header to issue if the help output has a section for documented commands.</p>
 
256
</dd></dl>
 
257
 
 
258
<dl class="attribute">
 
259
<dt id="cmd.Cmd.misc_header">
 
260
<code class="descclassname">Cmd.</code><code class="descname">misc_header</code><a class="headerlink" href="#cmd.Cmd.misc_header" title="Permalink to this definition">¶</a></dt>
 
261
<dd><p>The header to issue if the help output has a section for miscellaneous  help
 
262
topics (that is, there are <code class="xref py py-meth docutils literal"><span class="pre">help_*()</span></code> methods without corresponding
 
263
<code class="xref py py-meth docutils literal"><span class="pre">do_*()</span></code> methods).</p>
 
264
</dd></dl>
 
265
 
 
266
<dl class="attribute">
 
267
<dt id="cmd.Cmd.undoc_header">
 
268
<code class="descclassname">Cmd.</code><code class="descname">undoc_header</code><a class="headerlink" href="#cmd.Cmd.undoc_header" title="Permalink to this definition">¶</a></dt>
 
269
<dd><p>The header to issue if the help output has a section for undocumented  commands
 
270
(that is, there are <code class="xref py py-meth docutils literal"><span class="pre">do_*()</span></code> methods without corresponding <code class="xref py py-meth docutils literal"><span class="pre">help_*()</span></code>
 
271
methods).</p>
 
272
</dd></dl>
 
273
 
 
274
<dl class="attribute">
 
275
<dt id="cmd.Cmd.ruler">
 
276
<code class="descclassname">Cmd.</code><code class="descname">ruler</code><a class="headerlink" href="#cmd.Cmd.ruler" title="Permalink to this definition">¶</a></dt>
 
277
<dd><p>The character used to draw separator lines under the help-message headers.  If
 
278
empty, no ruler line is drawn.  It defaults to <code class="docutils literal"><span class="pre">'='</span></code>.</p>
 
279
</dd></dl>
 
280
 
 
281
<dl class="attribute">
 
282
<dt id="cmd.Cmd.use_rawinput">
 
283
<code class="descclassname">Cmd.</code><code class="descname">use_rawinput</code><a class="headerlink" href="#cmd.Cmd.use_rawinput" title="Permalink to this definition">¶</a></dt>
 
284
<dd><p>A flag, defaulting to true.  If true, <a class="reference internal" href="#cmd.Cmd.cmdloop" title="cmd.Cmd.cmdloop"><code class="xref py py-meth docutils literal"><span class="pre">cmdloop()</span></code></a> uses <a class="reference internal" href="functions.html#raw_input" title="raw_input"><code class="xref py py-func docutils literal"><span class="pre">raw_input()</span></code></a> to
 
285
display a prompt and read the next command; if false, <code class="xref py py-meth docutils literal"><span class="pre">sys.stdout.write()</span></code>
 
286
and <code class="xref py py-meth docutils literal"><span class="pre">sys.stdin.readline()</span></code> are used. (This means that by importing
 
287
<a class="reference internal" href="readline.html#module-readline" title="readline: GNU readline support for Python. (Unix)"><code class="xref py py-mod docutils literal"><span class="pre">readline</span></code></a>, on systems that support it, the interpreter will automatically
 
288
support <strong class="program">Emacs</strong>-like line editing  and command-history keystrokes.)</p>
 
289
</dd></dl>
 
290
 
 
291
</div>
 
292
</div>
 
293
 
 
294
 
 
295
          </div>
 
296
        </div>
 
297
      </div>
 
298
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
 
299
        <div class="sphinxsidebarwrapper">
 
300
  <h3><a href="../contents.html">Table Of Contents</a></h3>
 
301
  <ul>
 
302
<li><a class="reference internal" href="#">23.1. <code class="docutils literal"><span class="pre">cmd</span></code> &#8212; Support for line-oriented command interpreters</a><ul>
 
303
<li><a class="reference internal" href="#cmd-objects">23.1.1. Cmd Objects</a></li>
 
304
</ul>
 
305
</li>
 
306
</ul>
 
307
 
 
308
  <h4>Previous topic</h4>
 
309
  <p class="topless"><a href="frameworks.html"
 
310
                        title="previous chapter">23. Program Frameworks</a></p>
 
311
  <h4>Next topic</h4>
 
312
  <p class="topless"><a href="shlex.html"
 
313
                        title="next chapter">23.2. <code class="docutils literal"><span class="pre">shlex</span></code> &#8212; Simple lexical analysis</a></p>
 
314
<h3>This Page</h3>
 
315
<ul class="this-page-menu">
 
316
  <li><a href="../bugs.html">Report a Bug</a></li>
 
317
  <li><a href="../_sources/library/cmd.txt"
 
318
         rel="nofollow">Show Source</a></li>
 
319
</ul>
 
320
 
 
321
<div id="searchbox" style="display: none" role="search">
 
322
  <h3>Quick search</h3>
 
323
    <form class="search" action="../search.html" method="get">
 
324
      <input type="text" name="q" />
 
325
      <input type="submit" value="Go" />
 
326
      <input type="hidden" name="check_keywords" value="yes" />
 
327
      <input type="hidden" name="area" value="default" />
 
328
    </form>
 
329
    <p class="searchtip" style="font-size: 90%">
 
330
    Enter search terms or a module, class or function name.
 
331
    </p>
 
332
</div>
 
333
<script type="text/javascript">$('#searchbox').show(0);</script>
 
334
        </div>
 
335
      </div>
 
336
      <div class="clearer"></div>
 
337
    </div>  
 
338
    <div class="related" role="navigation" aria-label="related navigation">
 
339
      <h3>Navigation</h3>
 
340
      <ul>
 
341
        <li class="right" style="margin-right: 10px">
 
342
          <a href="../genindex.html" title="General Index"
 
343
             >index</a></li>
 
344
        <li class="right" >
 
345
          <a href="../py-modindex.html" title="Python Module Index"
 
346
             >modules</a> |</li>
 
347
        <li class="right" >
 
348
          <a href="shlex.html" title="23.2. shlex — Simple lexical analysis"
 
349
             >next</a> |</li>
 
350
        <li class="right" >
 
351
          <a href="frameworks.html" title="23. Program Frameworks"
 
352
             >previous</a> |</li>
 
353
        <li><img src="../_static/py.png" alt=""
 
354
                 style="vertical-align: middle; margin-top: -1px"/></li>
 
355
        <li><a href="https://www.python.org/">Python</a> &raquo;</li>
 
356
        <li>
 
357
          <span class="version_switcher_placeholder">2.7.12</span>
 
358
          <a href="../index.html">Documentation</a> &raquo;
 
359
        </li>
 
360
 
 
361
          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &raquo;</li>
 
362
          <li class="nav-item nav-item-2"><a href="frameworks.html" >23. Program Frameworks</a> &raquo;</li> 
 
363
      </ul>
 
364
    </div>  
 
365
    <div class="footer">
 
366
    &copy; <a href="../copyright.html">Copyright</a> 1990-2016, Python Software Foundation.
 
367
    <br />
 
368
    The Python Software Foundation is a non-profit corporation.
 
369
    <a href="https://www.python.org/psf/donations/">Please donate.</a>
 
370
    <br />
 
371
    Last updated on Sep 20, 2016.
 
372
    <a href="../bugs.html">Found a bug</a>?
 
373
    <br />
 
374
    Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.3.3.
 
375
    </div>
 
376
 
 
377
  </body>
 
378
</html>
 
 
b'\\ No newline at end of file'