[code.view]

[top] / python / PyMOTW / docs / rlcompleter / index.html


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>rlcompleter – Adds tab-completion to the interactive interpreter &mdash; Python Module of the Week</title>
    <link rel="stylesheet" href="../_static/sphinxdoc.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '1.132',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="author" title="About these documents" href="../about.html" />
    <link rel="top" title="Python Module of the Week" href="../index.html" />
    <link rel="up" title="Optional Operating System Services" href="../optional_os.html" />
    <link rel="next" title="Unix-specific Services" href="../unix.html" />
    <link rel="prev" title="readline – Interface to the GNU readline library" href="../readline/index.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="../unix.html" title="Unix-specific Services"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="../readline/index.html" title="readline – Interface to the GNU readline library"
             accesskey="P">previous</a> |</li>
        <li><a href="../contents.html">PyMOTW</a> &raquo;</li>
          <li><a href="../optional_os.html" accesskey="U">Optional Operating System Services</a> &raquo;</li> 
      </ul>
    </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h4>Previous topic</h4>
  <p class="topless"><a href="../readline/index.html"
                        title="previous chapter">readline &#8211; Interface to the GNU readline library</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="../unix.html"
                        title="next chapter">Unix-specific Services</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../_sources/rlcompleter/index.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" size="18" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="module-rlcompleter">
<span id="rlcompleter-adds-tab-completion-to-the-interactive-interpreter"></span><h1>rlcompleter &#8211; Adds tab-completion to the interactive interpreter<a class="headerlink" href="#module-rlcompleter" title="Permalink to this headline">¶</a></h1>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Purpose:</th><td class="field-body">Adds tab-completion to the interactive interpreter</td>
</tr>
<tr class="field"><th class="field-name">Python Version:</th><td class="field-body">1.5 and later</td>
</tr>
</tbody>
</table>
<p><a class="reference internal" href="#module-rlcompleter" title="rlcompleter: Adds tab-completion to the interactive interpreter"><tt class="xref py py-mod docutils literal"><span class="pre">rlcompleter</span></tt></a> adds tab-completion for Python symbols to the
interactive interpreter.  Importing the module causes it to configure
a completer function for <a class="reference internal" href="../readline/index.html#module-readline" title="readline: Interface to the GNU readline library"><tt class="xref py py-mod docutils literal"><span class="pre">readline</span></tt></a>.  The only other step
required is to configure the tab key to trigger the completer.  All of
this can be done in a <a class="reference external" href="http://docs.python.org/using/cmdline.html#envvar-PYTHONSTARTUP">PYTHONSTARTUP</a>
file so that it runs each time the interactive interpreter starts.</p>
<p>For example, create a file <tt class="docutils literal"><span class="pre">~/.pythonrc</span></tt> containing:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">try</span><span class="p">:</span>
    <span class="kn">import</span> <span class="nn">readline</span>
<span class="k">except</span> <span class="ne">ImportError</span><span class="p">:</span>
    <span class="c"># Silently ignore missing readline module</span>
    <span class="k">pass</span>
<span class="k">else</span><span class="p">:</span>
    <span class="kn">import</span> <span class="nn">rlcompleter</span>
    <span class="n">readline</span><span class="o">.</span><span class="n">parse_and_bind</span><span class="p">(</span><span class="s">&quot;tab: complete&quot;</span><span class="p">)</span>
</pre></div>
</div>
<p>Then set <tt class="docutils literal"><span class="pre">PYTHONSTARTUP</span></tt> to <tt class="docutils literal"><span class="pre">&quot;~/.pythonrc&quot;</span></tt>.  When you start the
interactive interpreter, tab completion for names from the contents of
modules or attributes of objects is activated.</p>
<div class="admonition-see-also admonition seealso">
<p class="first admonition-title">See also</p>
<dl class="last docutils">
<dt><a class="reference external" href="http://docs.python.org/library/rlcompleter.html">rlcompleter</a></dt>
<dd>The standard library documentation for this module.</dd>
<dt><a class="reference internal" href="../readline/index.html#module-readline" title="readline: Interface to the GNU readline library"><tt class="xref py py-mod docutils literal"><span class="pre">readline</span></tt></a></dt>
<dd>The readline module.</dd>
</dl>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="../unix.html" title="Unix-specific Services"
             >next</a> |</li>
        <li class="right" >
          <a href="../readline/index.html" title="readline – Interface to the GNU readline library"
             >previous</a> |</li>
        <li><a href="../contents.html">PyMOTW</a> &raquo;</li>
          <li><a href="../optional_os.html" >Optional Operating System Services</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
      &copy; Copyright Doug Hellmann.
      Last updated on Oct 24, 2010.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a>.

    <br/><a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/" rel="license"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-nc-sa/3.0/us/88x31.png"/></a>
    
    </div>
  </body>
</html>

[top] / python / PyMOTW / docs / rlcompleter / index.html

contact | logmethods.com