| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
| 2 | <html> |
| 3 | <head> |
| 4 | <link rel="STYLESHEET" href="lib.css" type='text/css' /> |
| 5 | <link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" /> |
| 6 | <link rel='start' href='../index.html' title='Python Documentation Index' /> |
| 7 | <link rel="first" href="lib.html" title='Python Library Reference' /> |
| 8 | <link rel='contents' href='contents.html' title="Contents" /> |
| 9 | <link rel='index' href='genindex.html' title='Index' /> |
| 10 | <link rel='last' href='about.html' title='About this document...' /> |
| 11 | <link rel='help' href='about.html' title='About this document...' /> |
| 12 | <link rel="prev" href="module-readline.html" /> |
| 13 | <link rel="parent" href="someos.html" /> |
| 14 | <link rel="next" href="completer-objects.html" /> |
| 15 | <meta name='aesop' content='information' /> |
| 16 | <title>7.21 rlcompleter -- Completion function for GNU readline</title> |
| 17 | </head> |
| 18 | <body> |
| 19 | <DIV CLASS="navigation"> |
| 20 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> |
| 21 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> |
| 22 | <tr> |
| 23 | <td class='online-navigation'><a rel="prev" title="7.20.1 Example" |
| 24 | href="readline-example.html"><img src='../icons/previous.png' |
| 25 | border='0' height='32' alt='Previous Page' width='32' /></A></td> |
| 26 | <td class='online-navigation'><a rel="parent" title="7. Optional Operating System" |
| 27 | href="someos.html"><img src='../icons/up.png' |
| 28 | border='0' height='32' alt='Up One Level' width='32' /></A></td> |
| 29 | <td class='online-navigation'><a rel="next" title="7.21.1 Completer Objects" |
| 30 | href="completer-objects.html"><img src='../icons/next.png' |
| 31 | border='0' height='32' alt='Next Page' width='32' /></A></td> |
| 32 | <td align="center" width="100%">Python Library Reference</td> |
| 33 | <td class='online-navigation'><a rel="contents" title="Table of Contents" |
| 34 | href="contents.html"><img src='../icons/contents.png' |
| 35 | border='0' height='32' alt='Contents' width='32' /></A></td> |
| 36 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' |
| 37 | border='0' height='32' alt='Module Index' width='32' /></a></td> |
| 38 | <td class='online-navigation'><a rel="index" title="Index" |
| 39 | href="genindex.html"><img src='../icons/index.png' |
| 40 | border='0' height='32' alt='Index' width='32' /></A></td> |
| 41 | </tr></table> |
| 42 | <div class='online-navigation'> |
| 43 | <b class="navlabel">Previous:</b> |
| 44 | <a class="sectref" rel="prev" href="readline-example.html">7.20.1 Example</A> |
| 45 | <b class="navlabel">Up:</b> |
| 46 | <a class="sectref" rel="parent" href="someos.html">7. Optional Operating System</A> |
| 47 | <b class="navlabel">Next:</b> |
| 48 | <a class="sectref" rel="next" href="completer-objects.html">7.21.1 Completer Objects</A> |
| 49 | </div> |
| 50 | <hr /></div> |
| 51 | </DIV> |
| 52 | <!--End of Navigation Panel--> |
| 53 | |
| 54 | <H1><A NAME="SECTION0092100000000000000000"> |
| 55 | 7.21 <tt class="module">rlcompleter</tt> -- |
| 56 | Completion function for GNU readline</A> |
| 57 | </H1> |
| 58 | |
| 59 | <P> |
| 60 | <A NAME="module-rlcompleter"></A> |
| 61 | <p class="availability">Availability: <span |
| 62 | class="platform">Unix</span>.</p> |
| 63 | |
| 64 | <P> |
| 65 | The <tt class="module">rlcompleter</tt> module defines a completion function for |
| 66 | the <tt class="module"><a href="module-readline.html">readline</a></tt> module by completing valid Python identifiers |
| 67 | and keywords. |
| 68 | |
| 69 | <P> |
| 70 | This module is <span class="Unix">Unix</span>-specific due to its dependence on the |
| 71 | <tt class="module"><a href="module-readline.html">readline</a></tt> module. |
| 72 | |
| 73 | <P> |
| 74 | The <tt class="module">rlcompleter</tt> module defines the <tt class="class">Completer</tt> class. |
| 75 | |
| 76 | <P> |
| 77 | Example: |
| 78 | |
| 79 | <P> |
| 80 | <div class="verbatim"><pre> |
| 81 | >>> import rlcompleter |
| 82 | >>> import readline |
| 83 | >>> readline.parse_and_bind("tab: complete") |
| 84 | >>> readline. <TAB PRESSED> |
| 85 | readline.__doc__ readline.get_line_buffer readline.read_init_file |
| 86 | readline.__file__ readline.insert_text readline.set_completer |
| 87 | readline.__name__ readline.parse_and_bind |
| 88 | >>> readline. |
| 89 | </pre></div> |
| 90 | |
| 91 | <P> |
| 92 | The <tt class="module">rlcompleter</tt> module is designed for use with Python's |
| 93 | interactive mode. A user can add the following lines to his or her |
| 94 | initialization file (identified by the <a class="envvar" id='l2h-2966' xml:id='l2h-2966'>PYTHONSTARTUP</a> |
| 95 | environment variable) to get automatic <kbd>Tab</kbd> completion: |
| 96 | |
| 97 | <P> |
| 98 | <div class="verbatim"><pre> |
| 99 | try: |
| 100 | import readline |
| 101 | except ImportError: |
| 102 | print "Module readline not available." |
| 103 | else: |
| 104 | import rlcompleter |
| 105 | readline.parse_and_bind("tab: complete") |
| 106 | </pre></div> |
| 107 | |
| 108 | <P> |
| 109 | |
| 110 | <p><br /></p><hr class='online-navigation' /> |
| 111 | <div class='online-navigation'> |
| 112 | <!--Table of Child-Links--> |
| 113 | <A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></a> |
| 114 | |
| 115 | <UL CLASS="ChildLinks"> |
| 116 | <LI><A href="completer-objects.html">7.21.1 Completer Objects</a> |
| 117 | </ul> |
| 118 | <!--End of Table of Child-Links--> |
| 119 | </div> |
| 120 | |
| 121 | <DIV CLASS="navigation"> |
| 122 | <div class='online-navigation'> |
| 123 | <p></p><hr /> |
| 124 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> |
| 125 | <tr> |
| 126 | <td class='online-navigation'><a rel="prev" title="7.20.1 Example" |
| 127 | href="readline-example.html"><img src='../icons/previous.png' |
| 128 | border='0' height='32' alt='Previous Page' width='32' /></A></td> |
| 129 | <td class='online-navigation'><a rel="parent" title="7. Optional Operating System" |
| 130 | href="someos.html"><img src='../icons/up.png' |
| 131 | border='0' height='32' alt='Up One Level' width='32' /></A></td> |
| 132 | <td class='online-navigation'><a rel="next" title="7.21.1 Completer Objects" |
| 133 | href="completer-objects.html"><img src='../icons/next.png' |
| 134 | border='0' height='32' alt='Next Page' width='32' /></A></td> |
| 135 | <td align="center" width="100%">Python Library Reference</td> |
| 136 | <td class='online-navigation'><a rel="contents" title="Table of Contents" |
| 137 | href="contents.html"><img src='../icons/contents.png' |
| 138 | border='0' height='32' alt='Contents' width='32' /></A></td> |
| 139 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' |
| 140 | border='0' height='32' alt='Module Index' width='32' /></a></td> |
| 141 | <td class='online-navigation'><a rel="index" title="Index" |
| 142 | href="genindex.html"><img src='../icons/index.png' |
| 143 | border='0' height='32' alt='Index' width='32' /></A></td> |
| 144 | </tr></table> |
| 145 | <div class='online-navigation'> |
| 146 | <b class="navlabel">Previous:</b> |
| 147 | <a class="sectref" rel="prev" href="readline-example.html">7.20.1 Example</A> |
| 148 | <b class="navlabel">Up:</b> |
| 149 | <a class="sectref" rel="parent" href="someos.html">7. Optional Operating System</A> |
| 150 | <b class="navlabel">Next:</b> |
| 151 | <a class="sectref" rel="next" href="completer-objects.html">7.21.1 Completer Objects</A> |
| 152 | </div> |
| 153 | </div> |
| 154 | <hr /> |
| 155 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> |
| 156 | </DIV> |
| 157 | <!--End of Navigation Panel--> |
| 158 | <ADDRESS> |
| 159 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. |
| 160 | </ADDRESS> |
| 161 | </BODY> |
| 162 | </HTML> |