Home | History | Annotate | Download | only in idlelib
      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>24.6. IDLE &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="24. Graphical User Interfaces with Tk" href="tk.html" />
     34     <link rel="next" title="24.7. Other Graphical User Interface Packages" href="othergui.html" />
     35     <link rel="prev" title="24.5. turtle  Turtle graphics for Tk" href="turtle.html" />
     36     <link rel="shortcut icon" type="image/png" href="../_static/py.png" />
     37     <script type="text/javascript" src="../_static/copybutton.js"></script>
     38 
     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="othergui.html" title="24.7. Other Graphical User Interface Packages"
     55              accesskey="N">next</a> |</li>
     56         <li class="right" >
     57           <a href="turtle.html" title="24.5. turtle  Turtle graphics for Tk"
     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           <a href="../index.html">Python 2.7.12 documentation</a> &raquo;
     64         </li>
     65 
     66           <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &raquo;</li>
     67           <li class="nav-item nav-item-2"><a href="tk.html" accesskey="U">24. Graphical User Interfaces with Tk</a> &raquo;</li>
     68       </ul>
     69     </div>
     70 
     71     <div class="document">
     72       <div class="documentwrapper">
     73         <div class="bodywrapper">
     74           <div class="body" role="main">
     75 
     76   <div class="section" id="idle">
     77 <span id="id1"></span><h1>24.6. IDLE<a class="headerlink" href="#idle" title="Permalink to this headline"></a></h1>
     78 <p id="index-0">IDLE is Python&#8217;s Integrated Development and Learning Environment.</p>
     79 <p>IDLE has the following features:</p>
     80 <ul class="simple">
     81 <li>coded in 100% pure Python, using the <code class="xref py py-mod docutils literal"><span class="pre">tkinter</span></code> GUI toolkit</li>
     82 <li>cross-platform: works mostly the same on Windows, Unix, and Mac OS X</li>
     83 <li>Python shell window (interactive interpreter) with colorizing
     84 of code input, output, and error messages</li>
     85 <li>multi-window text editor with multiple undo, Python colorizing,
     86 smart indent, call tips, auto completion, and other features</li>
     87 <li>search within any window, replace within editor windows, and search
     88 through multiple files (grep)</li>
     89 <li>debugger with persistent breakpoints, stepping, and viewing
     90 of global and local namespaces</li>
     91 <li>configuration, browsers, and other dialogs</li>
     92 </ul>
     93 <div class="section" id="menus">
     94 <h2>24.6.1. Menus<a class="headerlink" href="#menus" title="Permalink to this headline"></a></h2>
     95 <p>IDLE has two main window types, the Shell window and the Editor window.  It is
     96 possible to have multiple editor windows simultaneously.  Output windows, such
     97 as used for Edit / Find in Files, are a subtype of edit window.  They currently
     98 have the same top menu as Editor windows but a different default title and
     99 context menu.</p>
    100 <p>IDLE&#8217;s menus dynamically change based on which window is currently selected.
    101 Each menu documented below indicates which window type it is associated with.</p>
    102 <div class="section" id="file-menu-shell-and-editor">
    103 <h3>24.6.1.1. File menu (Shell and Editor)<a class="headerlink" href="#file-menu-shell-and-editor" title="Permalink to this headline"></a></h3>
    104 <dl class="docutils">
    105 <dt>New File</dt>
    106 <dd>Create a new file editing window.</dd>
    107 <dt>Open...</dt>
    108 <dd>Open an existing file with an Open dialog.</dd>
    109 <dt>Recent Files</dt>
    110 <dd>Open a list of recent files.  Click one to open it.</dd>
    111 <dt>Open Module...</dt>
    112 <dd>Open an existing module (searches sys.path).</dd>
    113 </dl>
    114 <dl class="docutils" id="index-1">
    115 <dt>Class Browser</dt>
    116 <dd>Show functions, classes, and methods in the current Editor file in a
    117 tree structure.  In the shell, open a module first.</dd>
    118 <dt>Path Browser</dt>
    119 <dd>Show sys.path directories, modules, functions, classes and methods in a
    120 tree structure.</dd>
    121 <dt>Save</dt>
    122 <dd>Save the current window to the associated file, if there is one.  Windows
    123 that have been changed since being opened or last saved have a * before
    124 and after the window title.  If there is no associated file,
    125 do Save As instead.</dd>
    126 <dt>Save As...</dt>
    127 <dd>Save the current window with a Save As dialog.  The file saved becomes the
    128 new associated file for the window.</dd>
    129 <dt>Save Copy As...</dt>
    130 <dd>Save the current window to different file without changing the associated
    131 file.</dd>
    132 <dt>Print Window</dt>
    133 <dd>Print the current window to the default printer.</dd>
    134 <dt>Close</dt>
    135 <dd>Close the current window (ask to save if unsaved).</dd>
    136 <dt>Exit</dt>
    137 <dd>Close all windows and quit IDLE (ask to save unsaved windows).</dd>
    138 </dl>
    139 </div>
    140 <div class="section" id="edit-menu-shell-and-editor">
    141 <h3>24.6.1.2. Edit menu (Shell and Editor)<a class="headerlink" href="#edit-menu-shell-and-editor" title="Permalink to this headline"></a></h3>
    142 <dl class="docutils">
    143 <dt>Undo</dt>
    144 <dd>Undo the last change to the current window.  A maximum of 1000 changes may
    145 be undone.</dd>
    146 <dt>Redo</dt>
    147 <dd>Redo the last undone change to the current window.</dd>
    148 <dt>Cut</dt>
    149 <dd>Copy selection into the system-wide clipboard; then delete the selection.</dd>
    150 <dt>Copy</dt>
    151 <dd>Copy selection into the system-wide clipboard.</dd>
    152 <dt>Paste</dt>
    153 <dd>Insert contents of the system-wide clipboard into the current window.</dd>
    154 </dl>
    155 <p>The clipboard functions are also available in context menus.</p>
    156 <dl class="docutils">
    157 <dt>Select All</dt>
    158 <dd>Select the entire contents of the current window.</dd>
    159 <dt>Find...</dt>
    160 <dd>Open a search dialog with many options</dd>
    161 <dt>Find Again</dt>
    162 <dd>Repeat the last search, if there is one.</dd>
    163 <dt>Find Selection</dt>
    164 <dd>Search for the currently selected string, if there is one.</dd>
    165 <dt>Find in Files...</dt>
    166 <dd>Open a file search dialog.  Put results in a new output window.</dd>
    167 <dt>Replace...</dt>
    168 <dd>Open a search-and-replace dialog.</dd>
    169 <dt>Go to Line</dt>
    170 <dd>Move cursor to the line number requested and make that line visible.</dd>
    171 <dt>Show Completions</dt>
    172 <dd>Open a scrollable list allowing selection of keywords and attributes. See
    173 Completions in the Tips sections below.</dd>
    174 <dt>Expand Word</dt>
    175 <dd>Expand a prefix you have typed to match a full word in the same window;
    176 repeat to get a different expansion.</dd>
    177 <dt>Show call tip</dt>
    178 <dd>After an unclosed parenthesis for a function, open a small window with
    179 function parameter hints.</dd>
    180 <dt>Show surrounding parens</dt>
    181 <dd>Highlight the surrounding parenthesis.</dd>
    182 </dl>
    183 </div>
    184 <div class="section" id="format-menu-editor-window-only">
    185 <h3>24.6.1.3. Format menu (Editor window only)<a class="headerlink" href="#format-menu-editor-window-only" title="Permalink to this headline"></a></h3>
    186 <dl class="docutils">
    187 <dt>Indent Region</dt>
    188 <dd>Shift selected lines right by the indent width (default 4 spaces).</dd>
    189 <dt>Dedent Region</dt>
    190 <dd>Shift selected lines left by the indent width (default 4 spaces).</dd>
    191 <dt>Comment Out Region</dt>
    192 <dd>Insert ## in front of selected lines.</dd>
    193 <dt>Uncomment Region</dt>
    194 <dd>Remove leading # or ## from selected lines.</dd>
    195 <dt>Tabify Region</dt>
    196 <dd>Turn <em>leading</em> stretches of spaces into tabs. (Note: We recommend using
    197 4 space blocks to indent Python code.)</dd>
    198 <dt>Untabify Region</dt>
    199 <dd>Turn <em>all</em> tabs into the correct number of spaces.</dd>
    200 <dt>Toggle Tabs</dt>
    201 <dd>Open a dialog to switch between indenting with spaces and tabs.</dd>
    202 <dt>New Indent Width</dt>
    203 <dd>Open a dialog to change indent width. The accepted default by the Python
    204 community is 4 spaces.</dd>
    205 <dt>Format Paragraph</dt>
    206 <dd>Reformat the current blank-line-delimited paragraph in comment block or
    207 multiline string or selected line in a string.  All lines in the
    208 paragraph will be formatted to less than N columns, where N defaults to 72.</dd>
    209 <dt>Strip trailing whitespace</dt>
    210 <dd>Remove any space characters after the last non-space character of a line.</dd>
    211 </dl>
    212 </div>
    213 <div class="section" id="run-menu-editor-window-only">
    214 <span id="index-2"></span><h3>24.6.1.4. Run menu (Editor window only)<a class="headerlink" href="#run-menu-editor-window-only" title="Permalink to this headline"></a></h3>
    215 <dl class="docutils">
    216 <dt>Python Shell</dt>
    217 <dd>Open or wake up the Python Shell window.</dd>
    218 <dt>Check Module</dt>
    219 <dd>Check the syntax of the module currently open in the Editor window. If the
    220 module has not been saved IDLE will either prompt the user to save or
    221 autosave, as selected in the General tab of the Idle Settings dialog.  If
    222 there is a syntax error, the approximate location is indicated in the
    223 Editor window.</dd>
    224 <dt>Run Module</dt>
    225 <dd>Do Check Module (above).  If no error, restart the shell to clean the
    226 environment, then execute the module.  Output is displayed in the Shell
    227 window.  Note that output requires use of <code class="docutils literal"><span class="pre">print</span></code> or <code class="docutils literal"><span class="pre">write</span></code>.
    228 When execution is complete, the Shell retains focus and displays a prompt.
    229 At this point, one may interactively explore the result of execution.
    230 This is similar to executing a file with <code class="docutils literal"><span class="pre">python</span> <span class="pre">-i</span> <span class="pre">file</span></code> at a command
    231 line.</dd>
    232 </dl>
    233 </div>
    234 <div class="section" id="shell-menu-shell-window-only">
    235 <h3>24.6.1.5. Shell menu (Shell window only)<a class="headerlink" href="#shell-menu-shell-window-only" title="Permalink to this headline"></a></h3>
    236 <dl class="docutils">
    237 <dt>View Last Restart</dt>
    238 <dd>Scroll the shell window to the last Shell restart.</dd>
    239 <dt>Restart Shell</dt>
    240 <dd>Restart the shell to clean the environment.</dd>
    241 <dt>Interrupt Execution</dt>
    242 <dd>Stop a running program.</dd>
    243 </dl>
    244 </div>
    245 <div class="section" id="debug-menu-shell-window-only">
    246 <h3>24.6.1.6. Debug menu (Shell window only)<a class="headerlink" href="#debug-menu-shell-window-only" title="Permalink to this headline"></a></h3>
    247 <dl class="docutils">
    248 <dt>Go to File/Line</dt>
    249 <dd>Look on the current line. with the cursor, and the line above for a filename
    250 and line number.  If found, open the file if not already open, and show the
    251 line.  Use this to view source lines referenced in an exception traceback
    252 and lines found by Find in Files. Also available in the context menu of
    253 the Shell window and Output windows.</dd>
    254 </dl>
    255 <dl class="docutils" id="index-3">
    256 <dt>Debugger (toggle)</dt>
    257 <dd>When actived, code entered in the Shell or run from an Editor will run
    258 under the debugger.  In the Editor, breakpoints can be set with the context
    259 menu.  This feature is still incomplete and somewhat experimental.</dd>
    260 <dt>Stack Viewer</dt>
    261 <dd>Show the stack traceback of the last exception in a tree widget, with
    262 access to locals and globals.</dd>
    263 <dt>Auto-open Stack Viewer</dt>
    264 <dd>Toggle automatically opening the stack viewer on an unhandled exception.</dd>
    265 </dl>
    266 </div>
    267 <div class="section" id="options-menu-shell-and-editor">
    268 <h3>24.6.1.7. Options menu (Shell and Editor)<a class="headerlink" href="#options-menu-shell-and-editor" title="Permalink to this headline"></a></h3>
    269 <dl class="docutils">
    270 <dt>Configure IDLE</dt>
    271 <dd><p class="first">Open a configuration dialog and change preferences for the following:
    272 fonts, indentation, keybindings, text color themes, startup windows and
    273 size, additional help sources, and extensions (see below).  On OS X,
    274 open the configuration dialog by selecting Preferences in the application
    275 menu.  To use a new built-in color theme (IDLE Dark) with older IDLEs,
    276 save it as a new custom theme.</p>
    277 <p class="last">Non-default user settings are saved in a .idlerc directory in the user&#8217;s
    278 home directory.  Problems caused by bad user configuration files are solved
    279 by editing or deleting one or more of the files in .idlerc.</p>
    280 </dd>
    281 <dt>Code Context (toggle)(Editor Window only)</dt>
    282 <dd>Open a pane at the top of the edit window which shows the block context
    283 of the code which has scrolled above the top of the window.</dd>
    284 </dl>
    285 </div>
    286 <div class="section" id="window-menu-shell-and-editor">
    287 <h3>24.6.1.8. Window menu (Shell and Editor)<a class="headerlink" href="#window-menu-shell-and-editor" title="Permalink to this headline"></a></h3>
    288 <dl class="docutils">
    289 <dt>Zoom Height</dt>
    290 <dd>Toggles the window between normal size and maximum height. The initial size
    291 defaults to 40 lines by 80 chars unless changed on the General tab of the
    292 Configure IDLE dialog.</dd>
    293 </dl>
    294 <p>The rest of this menu lists the names of all open windows; select one to bring
    295 it to the foreground (deiconifying it if necessary).</p>
    296 </div>
    297 <div class="section" id="help-menu-shell-and-editor">
    298 <h3>24.6.1.9. Help menu (Shell and Editor)<a class="headerlink" href="#help-menu-shell-and-editor" title="Permalink to this headline"></a></h3>
    299 <dl class="docutils">
    300 <dt>About IDLE</dt>
    301 <dd>Display version, copyright, license, credits, and more.</dd>
    302 <dt>IDLE Help</dt>
    303 <dd>Display a help file for IDLE detailing the menu options, basic editing and
    304 navigation, and other tips.</dd>
    305 <dt>Python Docs</dt>
    306 <dd>Access local Python documentation, if installed, or start a web browser
    307 and open docs.python.org showing the latest Python documentation.</dd>
    308 <dt>Turtle Demo</dt>
    309 <dd>Run the turtledemo module with example python code and turtle drawings.</dd>
    310 </dl>
    311 <p>Additional help sources may be added here with the Configure IDLE dialog under
    312 the General tab.</p>
    313 </div>
    314 <div class="section" id="context-menus">
    315 <span id="index-4"></span><h3>24.6.1.10. Context Menus<a class="headerlink" href="#context-menus" title="Permalink to this headline"></a></h3>
    316 <p>Open a context menu by right-clicking in a window (Control-click on OS X).
    317 Context menus have the standard clipboard functions also on the Edit menu.</p>
    318 <dl class="docutils">
    319 <dt>Cut</dt>
    320 <dd>Copy selection into the system-wide clipboard; then delete the selection.</dd>
    321 <dt>Copy</dt>
    322 <dd>Copy selection into the system-wide clipboard.</dd>
    323 <dt>Paste</dt>
    324 <dd>Insert contents of the system-wide clipboard into the current window.</dd>
    325 </dl>
    326 <p>Editor windows also have breakpoint functions.  Lines with a breakpoint set are
    327 specially marked.  Breakpoints only have an effect when running under the
    328 debugger.  Breakpoints for a file are saved in the user&#8217;s .idlerc directory.</p>
    329 <dl class="docutils">
    330 <dt>Set Breakpoint</dt>
    331 <dd>Set a breakpoint on the current line.</dd>
    332 <dt>Clear Breakpoint</dt>
    333 <dd>Clear the breakpoint on that line.</dd>
    334 </dl>
    335 <p>Shell and Output windows have the following.</p>
    336 <dl class="docutils">
    337 <dt>Go to file/line</dt>
    338 <dd>Same as in Debug menu.</dd>
    339 </dl>
    340 </div>
    341 </div>
    342 <div class="section" id="editing-and-navigation">
    343 <h2>24.6.2. Editing and navigation<a class="headerlink" href="#editing-and-navigation" title="Permalink to this headline"></a></h2>
    344 <p>In this section, &#8216;C&#8217; refers to the <code class="kbd docutils literal"><span class="pre">Control</span></code> key on Windows and Unix and
    345 the <code class="kbd docutils literal"><span class="pre">Command</span></code> key on Mac OSX.</p>
    346 <ul>
    347 <li><p class="first"><code class="kbd docutils literal"><span class="pre">Backspace</span></code> deletes to the left; <code class="kbd docutils literal"><span class="pre">Del</span></code> deletes to the right</p>
    348 </li>
    349 <li><p class="first"><code class="kbd docutils literal"><span class="pre">C-Backspace</span></code> delete word left; <code class="kbd docutils literal"><span class="pre">C-Del</span></code> delete word to the right</p>
    350 </li>
    351 <li><p class="first">Arrow keys and <code class="kbd docutils literal"><span class="pre">Page</span> <span class="pre">Up</span></code>/<code class="kbd docutils literal"><span class="pre">Page</span> <span class="pre">Down</span></code> to move around</p>
    352 </li>
    353 <li><p class="first"><code class="kbd docutils literal"><span class="pre">C-LeftArrow</span></code> and <code class="kbd docutils literal"><span class="pre">C-RightArrow</span></code> moves by words</p>
    354 </li>
    355 <li><p class="first"><code class="kbd docutils literal"><span class="pre">Home</span></code>/<code class="kbd docutils literal"><span class="pre">End</span></code> go to begin/end of line</p>
    356 </li>
    357 <li><p class="first"><code class="kbd docutils literal"><span class="pre">C-Home</span></code>/<code class="kbd docutils literal"><span class="pre">C-End</span></code> go to begin/end of file</p>
    358 </li>
    359 <li><p class="first">Some useful Emacs bindings are inherited from Tcl/Tk:</p>
    360 <blockquote>
    361 <div><ul class="simple">
    362 <li><code class="kbd docutils literal"><span class="pre">C-a</span></code> beginning of line</li>
    363 <li><code class="kbd docutils literal"><span class="pre">C-e</span></code> end of line</li>
    364 <li><code class="kbd docutils literal"><span class="pre">C-k</span></code> kill line (but doesn&#8217;t put it in clipboard)</li>
    365 <li><code class="kbd docutils literal"><span class="pre">C-l</span></code> center window around the insertion point</li>
    366 <li><code class="kbd docutils literal"><span class="pre">C-b</span></code> go backwards one character without deleting (usually you can
    367 also use the cursor key for this)</li>
    368 <li><code class="kbd docutils literal"><span class="pre">C-f</span></code> go forward one character without deleting (usually you can
    369 also use the cursor key for this)</li>
    370 <li><code class="kbd docutils literal"><span class="pre">C-p</span></code> go up one line (usually you can also use the cursor key for
    371 this)</li>
    372 <li><code class="kbd docutils literal"><span class="pre">C-d</span></code> delete next character</li>
    373 </ul>
    374 </div></blockquote>
    375 </li>
    376 </ul>
    377 <p>Standard keybindings (like <code class="kbd docutils literal"><span class="pre">C-c</span></code> to copy and <code class="kbd docutils literal"><span class="pre">C-v</span></code> to paste)
    378 may work.  Keybindings are selected in the Configure IDLE dialog.</p>
    379 <div class="section" id="automatic-indentation">
    380 <h3>24.6.2.1. Automatic indentation<a class="headerlink" href="#automatic-indentation" title="Permalink to this headline"></a></h3>
    381 <p>After a block-opening statement, the next line is indented by 4 spaces (in the
    382 Python Shell window by one tab).  After certain keywords (break, return etc.)
    383 the next line is dedented.  In leading indentation, <code class="kbd docutils literal"><span class="pre">Backspace</span></code> deletes up
    384 to 4 spaces if they are there. <code class="kbd docutils literal"><span class="pre">Tab</span></code> inserts spaces (in the Python
    385 Shell window one tab), number depends on Indent width. Currently tabs
    386 are restricted to four spaces due to Tcl/Tk limitations.</p>
    387 <p>See also the indent/dedent region commands in the edit menu.</p>
    388 </div>
    389 <div class="section" id="completions">
    390 <h3>24.6.2.2. Completions<a class="headerlink" href="#completions" title="Permalink to this headline"></a></h3>
    391 <p>Completions are supplied for functions, classes, and attributes of classes,
    392 both built-in and user-defined. Completions are also provided for
    393 filenames.</p>
    394 <p>The AutoCompleteWindow (ACW) will open after a predefined delay (default is
    395 two seconds) after a &#8216;.&#8217; or (in a string) an os.sep is typed. If after one
    396 of those characters (plus zero or more other characters) a tab is typed
    397 the ACW will open immediately if a possible continuation is found.</p>
    398 <p>If there is only one possible completion for the characters entered, a
    399 <code class="kbd docutils literal"><span class="pre">Tab</span></code> will supply that completion without opening the ACW.</p>
    400 <p>&#8216;Show Completions&#8217; will force open a completions window, by default the
    401 <code class="kbd docutils literal"><span class="pre">C-space</span></code> will open a completions window. In an empty
    402 string, this will contain the files in the current directory. On a
    403 blank line, it will contain the built-in and user-defined functions and
    404 classes in the current name spaces, plus any modules imported. If some
    405 characters have been entered, the ACW will attempt to be more specific.</p>
    406 <p>If a string of characters is typed, the ACW selection will jump to the
    407 entry most closely matching those characters.  Entering a <code class="kbd docutils literal"><span class="pre">tab</span></code> will
    408 cause the longest non-ambiguous match to be entered in the Editor window or
    409 Shell.  Two <code class="kbd docutils literal"><span class="pre">tab</span></code> in a row will supply the current ACW selection, as
    410 will return or a double click.  Cursor keys, Page Up/Down, mouse selection,
    411 and the scroll wheel all operate on the ACW.</p>
    412 <p>&#8220;Hidden&#8221; attributes can be accessed by typing the beginning of hidden
    413 name after a &#8216;.&#8217;, e.g. &#8216;_&#8217;. This allows access to modules with
    414 <code class="docutils literal"><span class="pre">__all__</span></code> set, or to class-private attributes.</p>
    415 <p>Completions and the &#8216;Expand Word&#8217; facility can save a lot of typing!</p>
    416 <p>Completions are currently limited to those in the namespaces. Names in
    417 an Editor window which are not via <code class="docutils literal"><span class="pre">__main__</span></code> and <a class="reference internal" href="sys.html#sys.modules" title="sys.modules"><code class="xref py py-data docutils literal"><span class="pre">sys.modules</span></code></a> will
    418 not be found.  Run the module once with your imports to correct this situation.
    419 Note that IDLE itself places quite a few modules in sys.modules, so
    420 much can be found by default, e.g. the re module.</p>
    421 <p>If you don&#8217;t like the ACW popping up unbidden, simply make the delay
    422 longer or disable the extension.</p>
    423 </div>
    424 <div class="section" id="calltips">
    425 <h3>24.6.2.3. Calltips<a class="headerlink" href="#calltips" title="Permalink to this headline"></a></h3>
    426 <p>A calltip is shown when one types <code class="kbd docutils literal"><span class="pre">(</span></code> after the name of an <em>acccessible</em>
    427 function.  A name expression may include dots and subscripts.  A calltip
    428 remains until it is clicked, the cursor is moved out of the argument area,
    429 or <code class="kbd docutils literal"><span class="pre">)</span></code> is typed.  When the cursor is in the argument part of a definition,
    430 the menu or shortcut display a calltip.</p>
    431 <p>A calltip consists of the function signature and the first line of the
    432 docstring.  For builtins without an accessible signature, the calltip
    433 consists of all lines up the fifth line or the first blank line.  These
    434 details may change.</p>
    435 <p>The set of <em>accessible</em> functions depends on what modules have been imported
    436 into the user process, including those imported by Idle itself,
    437 and what definitions have been run, all since the last restart.</p>
    438 <p>For example, restart the Shell and enter <code class="docutils literal"><span class="pre">itertools.count(</span></code>.  A calltip
    439 appears because Idle imports itertools into the user process for its own use.
    440 (This could change.)  Enter <code class="docutils literal"><span class="pre">turtle.write(</span></code> and nothing appears.  Idle does
    441 not import turtle.  The menu or shortcut do nothing either.  Enter
    442 <code class="docutils literal"><span class="pre">import</span> <span class="pre">turtle</span></code> and then <code class="docutils literal"><span class="pre">turtle.write(</span></code> will work.</p>
    443 <p>In an editor, import statements have no effect until one runs the file.  One
    444 might want to run a file after writing the import statements at the top,
    445 or immediately run an existing file before editing.</p>
    446 </div>
    447 <div class="section" id="python-shell-window">
    448 <h3>24.6.2.4. Python Shell window<a class="headerlink" href="#python-shell-window" title="Permalink to this headline"></a></h3>
    449 <ul>
    450 <li><p class="first"><code class="kbd docutils literal"><span class="pre">C-c</span></code> interrupts executing command</p>
    451 </li>
    452 <li><p class="first"><code class="kbd docutils literal"><span class="pre">C-d</span></code> sends end-of-file; closes window if typed at a <code class="docutils literal"><span class="pre">&gt;&gt;&gt;</span></code> prompt</p>
    453 </li>
    454 <li><p class="first"><code class="kbd docutils literal"><span class="pre">Alt-/</span></code> (Expand word) is also useful to reduce typing</p>
    455 <p>Command history</p>
    456 <ul class="simple">
    457 <li><code class="kbd docutils literal"><span class="pre">Alt-p</span></code> retrieves previous command matching what you have typed. On
    458 OS X use <code class="kbd docutils literal"><span class="pre">C-p</span></code>.</li>
    459 <li><code class="kbd docutils literal"><span class="pre">Alt-n</span></code> retrieves next. On OS X use <code class="kbd docutils literal"><span class="pre">C-n</span></code>.</li>
    460 <li><code class="kbd docutils literal"><span class="pre">Return</span></code> while on any previous command retrieves that command</li>
    461 </ul>
    462 </li>
    463 </ul>
    464 </div>
    465 <div class="section" id="text-colors">
    466 <h3>24.6.2.5. Text colors<a class="headerlink" href="#text-colors" title="Permalink to this headline"></a></h3>
    467 <p>Idle defaults to black on white text, but colors text with special meanings.
    468 For the shell, these are shell output, shell error, user output, and
    469 user error.  For Python code, at the shell prompt or in an editor, these are
    470 keywords, builtin class and function names, names following <code class="docutils literal"><span class="pre">class</span></code> and
    471 <code class="docutils literal"><span class="pre">def</span></code>, strings, and comments. For any text window, these are the cursor (when
    472 present), found text (when possible), and selected text.</p>
    473 <p>Text coloring is done in the background, so uncolorized text is occasionally
    474 visible.  To change the color scheme, use the Configure IDLE dialog
    475 Highlighting tab.  The marking of debugger breakpoint lines in the editor and
    476 text in popups and dialogs is not user-configurable.</p>
    477 </div>
    478 </div>
    479 <div class="section" id="startup-and-code-execution">
    480 <h2>24.6.3. Startup and code execution<a class="headerlink" href="#startup-and-code-execution" title="Permalink to this headline"></a></h2>
    481 <p>Upon startup with the <code class="docutils literal"><span class="pre">-s</span></code> option, IDLE will execute the file referenced by
    482 the environment variables <span class="target" id="index-5"></span><code class="xref std std-envvar docutils literal"><span class="pre">IDLESTARTUP</span></code> or <span class="target" id="index-6"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONSTARTUP"><code class="xref std std-envvar docutils literal"><span class="pre">PYTHONSTARTUP</span></code></a>.
    483 IDLE first checks for <code class="docutils literal"><span class="pre">IDLESTARTUP</span></code>; if <code class="docutils literal"><span class="pre">IDLESTARTUP</span></code> is present the file
    484 referenced is run.  If <code class="docutils literal"><span class="pre">IDLESTARTUP</span></code> is not present, IDLE checks for
    485 <code class="docutils literal"><span class="pre">PYTHONSTARTUP</span></code>.  Files referenced by these environment variables are
    486 convenient places to store functions that are used frequently from the IDLE
    487 shell, or for executing import statements to import common modules.</p>
    488 <p>In addition, <code class="docutils literal"><span class="pre">Tk</span></code> also loads a startup file if it is present.  Note that the
    489 Tk file is loaded unconditionally.  This additional file is <code class="docutils literal"><span class="pre">.Idle.py</span></code> and is
    490 looked for in the user&#8217;s home directory.  Statements in this file will be
    491 executed in the Tk namespace, so this file is not useful for importing
    492 functions to be used from IDLE&#8217;s Python shell.</p>
    493 <div class="section" id="command-line-usage">
    494 <h3>24.6.3.1. Command line usage<a class="headerlink" href="#command-line-usage" title="Permalink to this headline"></a></h3>
    495 <div class="highlight-none"><div class="highlight"><pre><span></span>idle.py [-c command] [-d] [-e] [-h] [-i] [-r file] [-s] [-t title] [-] [arg] ...
    496 
    497 -c command  run command in the shell window
    498 -d          enable debugger and open shell window
    499 -e          open editor window
    500 -h          print help message with legal combinations and exit
    501 -i          open shell window
    502 -r file     run file in shell window
    503 -s          run $IDLESTARTUP or $PYTHONSTARTUP first, in shell window
    504 -t title    set title of shell window
    505 -           run stdin in shell (- must be last option before args)
    506 </pre></div>
    507 </div>
    508 <p>If there are arguments:</p>
    509 <ul class="simple">
    510 <li>If <code class="docutils literal"><span class="pre">-</span></code>, <code class="docutils literal"><span class="pre">-c</span></code>, or <code class="docutils literal"><span class="pre">r</span></code> is used, all arguments are placed in
    511 <code class="docutils literal"><span class="pre">sys.argv[1:...]</span></code> and <code class="docutils literal"><span class="pre">sys.argv[0]</span></code> is set to <code class="docutils literal"><span class="pre">''</span></code>, <code class="docutils literal"><span class="pre">'-c'</span></code>,
    512 or <code class="docutils literal"><span class="pre">'-r'</span></code>.  No editor window is opened, even if that is the default
    513 set in the Options dialog.</li>
    514 <li>Otherwise, arguments are files opened for editing and
    515 <code class="docutils literal"><span class="pre">sys.argv</span></code> reflects the arguments passed to IDLE itself.</li>
    516 </ul>
    517 </div>
    518 <div class="section" id="idle-console-differences">
    519 <h3>24.6.3.2. IDLE-console differences<a class="headerlink" href="#idle-console-differences" title="Permalink to this headline"></a></h3>
    520 <p>As much as possible, the result of executing Python code with IDLE is the
    521 same as executing the same code in a console window.  However, the different
    522 interface and operation occasionally affects visible results.  For instance,
    523 <code class="docutils literal"><span class="pre">sys.modules</span></code> starts with more entries.</p>
    524 <p>IDLE also replaces <code class="docutils literal"><span class="pre">sys.stdin</span></code>, <code class="docutils literal"><span class="pre">sys.stdout</span></code>, and <code class="docutils literal"><span class="pre">sys.stderr</span></code> with
    525 objects that get input from and send output to the Shell window.
    526 When this window has the focus, it controls the keyboard and screen.
    527 This is normally transparent, but functions that directly access the keyboard
    528 and screen will not work.  If <code class="docutils literal"><span class="pre">sys</span></code> is reset with <code class="docutils literal"><span class="pre">reload(sys)</span></code>,
    529 IDLE&#8217;s changes are lost and things like <code class="docutils literal"><span class="pre">input</span></code>, <code class="docutils literal"><span class="pre">raw_input</span></code>, and
    530 <code class="docutils literal"><span class="pre">print</span></code> will not work correctly.</p>
    531 <p>With IDLE&#8217;s Shell, one enters, edits, and recalls complete statements.
    532 Some consoles only work with a single physical line at a time.  IDLE uses
    533 <code class="docutils literal"><span class="pre">exec</span></code> to run each statement.  As a result, <code class="docutils literal"><span class="pre">'__builtins__'</span></code> is always
    534 defined for each statement.</p>
    535 </div>
    536 <div class="section" id="running-without-a-subprocess">
    537 <h3>24.6.3.3. Running without a subprocess<a class="headerlink" href="#running-without-a-subprocess" title="Permalink to this headline"></a></h3>
    538 <p>By default, IDLE executes user code in a separate subprocess via a socket,
    539 which uses the internal loopback interface.  This connection is not
    540 externally visible and no data is sent to or received from the Internet.
    541 If firewall software complains anyway, you can ignore it.</p>
    542 <p>If the attempt to make the socket connection fails, Idle will notify you.
    543 Such failures are sometimes transient, but if persistent, the problem
    544 may be either a firewall blocking the connecton or misconfiguration of
    545 a particular system.  Until the problem is fixed, one can run Idle with
    546 the -n command line switch.</p>
    547 <p>If IDLE is started with the -n command line switch it will run in a
    548 single process and will not create the subprocess which runs the RPC
    549 Python execution server.  This can be useful if Python cannot create
    550 the subprocess or the RPC socket interface on your platform.  However,
    551 in this mode user code is not isolated from IDLE itself.  Also, the
    552 environment is not restarted when Run/Run Module (F5) is selected.  If
    553 your code has been modified, you must reload() the affected modules and
    554 re-import any specific items (e.g. from foo import baz) if the changes
    555 are to take effect.  For these reasons, it is preferable to run IDLE
    556 with the default subprocess if at all possible.</p>
    557 <div class="deprecated">
    558 <p><span class="versionmodified">Deprecated since version 3.4.</span></p>
    559 </div>
    560 </div>
    561 </div>
    562 <div class="section" id="help-and-preferences">
    563 <h2>24.6.4. Help and preferences<a class="headerlink" href="#help-and-preferences" title="Permalink to this headline"></a></h2>
    564 <div class="section" id="additional-help-sources">
    565 <h3>24.6.4.1. Additional help sources<a class="headerlink" href="#additional-help-sources" title="Permalink to this headline"></a></h3>
    566 <p>IDLE includes a help menu entry called &#8220;Python Docs&#8221; that will open the
    567 extensive sources of help, including tutorials, available at docs.python.org.
    568 Selected URLs can be added or removed from the help menu at any time using the
    569 Configure IDLE dialog. See the IDLE help option in the help menu of IDLE for
    570 more information.</p>
    571 </div>
    572 <div class="section" id="setting-preferences">
    573 <h3>24.6.4.2. Setting preferences<a class="headerlink" href="#setting-preferences" title="Permalink to this headline"></a></h3>
    574 <p>The font preferences, highlighting, keys, and general preferences can be
    575 changed via Configure IDLE on the Option menu.  Keys can be user defined;
    576 IDLE ships with four built in key sets. In addition a user can create a
    577 custom key set in the Configure IDLE dialog under the keys tab.</p>
    578 </div>
    579 <div class="section" id="extensions">
    580 <h3>24.6.4.3. Extensions<a class="headerlink" href="#extensions" title="Permalink to this headline"></a></h3>
    581 <p>IDLE contains an extension facility.  Peferences for extensions can be
    582 changed with Configure Extensions. See the beginning of config-extensions.def
    583 in the idlelib directory for further information.  The default extensions
    584 are currently:</p>
    585 <ul class="simple">
    586 <li>FormatParagraph</li>
    587 <li>AutoExpand</li>
    588 <li>ZoomHeight</li>
    589 <li>ScriptBinding</li>
    590 <li>CallTips</li>
    591 <li>ParenMatch</li>
    592 <li>AutoComplete</li>
    593 <li>CodeContext</li>
    594 <li>RstripExtension</li>
    595 </ul>
    596 </div>
    597 </div>
    598 </div>
    599 
    600 
    601           </div>
    602         </div>
    603       </div>
    604       <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
    605         <div class="sphinxsidebarwrapper">
    606   <h3><a href="../contents.html">Table Of Contents</a></h3>
    607   <ul>
    608 <li><a class="reference internal" href="#">24.6. IDLE</a><ul>
    609 <li><a class="reference internal" href="#menus">24.6.1. Menus</a><ul>
    610 <li><a class="reference internal" href="#file-menu-shell-and-editor">24.6.1.1. File menu (Shell and Editor)</a></li>
    611 <li><a class="reference internal" href="#edit-menu-shell-and-editor">24.6.1.2. Edit menu (Shell and Editor)</a></li>
    612 <li><a class="reference internal" href="#format-menu-editor-window-only">24.6.1.3. Format menu (Editor window only)</a></li>
    613 <li><a class="reference internal" href="#run-menu-editor-window-only">24.6.1.4. Run menu (Editor window only)</a></li>
    614 <li><a class="reference internal" href="#shell-menu-shell-window-only">24.6.1.5. Shell menu (Shell window only)</a></li>
    615 <li><a class="reference internal" href="#debug-menu-shell-window-only">24.6.1.6. Debug menu (Shell window only)</a></li>
    616 <li><a class="reference internal" href="#options-menu-shell-and-editor">24.6.1.7. Options menu (Shell and Editor)</a></li>
    617 <li><a class="reference internal" href="#window-menu-shell-and-editor">24.6.1.8. Window menu (Shell and Editor)</a></li>
    618 <li><a class="reference internal" href="#help-menu-shell-and-editor">24.6.1.9. Help menu (Shell and Editor)</a></li>
    619 <li><a class="reference internal" href="#context-menus">24.6.1.10. Context Menus</a></li>
    620 </ul>
    621 </li>
    622 <li><a class="reference internal" href="#editing-and-navigation">24.6.2. Editing and navigation</a><ul>
    623 <li><a class="reference internal" href="#automatic-indentation">24.6.2.1. Automatic indentation</a></li>
    624 <li><a class="reference internal" href="#completions">24.6.2.2. Completions</a></li>
    625 <li><a class="reference internal" href="#calltips">24.6.2.3. Calltips</a></li>
    626 <li><a class="reference internal" href="#python-shell-window">24.6.2.4. Python Shell window</a></li>
    627 <li><a class="reference internal" href="#text-colors">24.6.2.5. Text colors</a></li>
    628 </ul>
    629 </li>
    630 <li><a class="reference internal" href="#startup-and-code-execution">24.6.3. Startup and code execution</a><ul>
    631 <li><a class="reference internal" href="#command-line-usage">24.6.3.1. Command line usage</a></li>
    632 <li><a class="reference internal" href="#idle-console-differences">24.6.3.2. IDLE-console differences</a></li>
    633 <li><a class="reference internal" href="#running-without-a-subprocess">24.6.3.3. Running without a subprocess</a></li>
    634 </ul>
    635 </li>
    636 <li><a class="reference internal" href="#help-and-preferences">24.6.4. Help and preferences</a><ul>
    637 <li><a class="reference internal" href="#additional-help-sources">24.6.4.1. Additional help sources</a></li>
    638 <li><a class="reference internal" href="#setting-preferences">24.6.4.2. Setting preferences</a></li>
    639 <li><a class="reference internal" href="#extensions">24.6.4.3. Extensions</a></li>
    640 </ul>
    641 </li>
    642 </ul>
    643 </li>
    644 </ul>
    645 
    646   <h4>Previous topic</h4>
    647   <p class="topless"><a href="turtle.html"
    648                         title="previous chapter">24.5. <code class="docutils literal"><span class="pre">turtle</span></code> &#8212; Turtle graphics for Tk</a></p>
    649   <h4>Next topic</h4>
    650   <p class="topless"><a href="othergui.html"
    651                         title="next chapter">24.7. Other Graphical User Interface Packages</a></p>
    652 <h3>This Page</h3>
    653 <ul class="this-page-menu">
    654   <li><a href="../bugs.html">Report a Bug</a></li>
    655   <li><a href="../_sources/library/idle.txt"
    656          rel="nofollow">Show Source</a></li>
    657 </ul>
    658 
    659 <div id="searchbox" style="display: none" role="search">
    660   <h3>Quick search</h3>
    661     <form class="search" action="../search.html" method="get">
    662       <input type="text" name="q" />
    663       <input type="submit" value="Go" />
    664       <input type="hidden" name="check_keywords" value="yes" />
    665       <input type="hidden" name="area" value="default" />
    666     </form>
    667     <p class="searchtip" style="font-size: 90%">
    668     Enter search terms or a module, class or function name.
    669     </p>
    670 </div>
    671 <script type="text/javascript">$('#searchbox').show(0);</script>
    672         </div>
    673       </div>
    674       <div class="clearer"></div>
    675     </div>
    676     <div class="related" role="navigation" aria-label="related navigation">
    677       <h3>Navigation</h3>
    678       <ul>
    679         <li class="right" style="margin-right: 10px">
    680           <a href="../genindex.html" title="General Index"
    681              >index</a></li>
    682         <li class="right" >
    683           <a href="../py-modindex.html" title="Python Module Index"
    684              >modules</a> |</li>
    685         <li class="right" >
    686           <a href="othergui.html" title="24.7. Other Graphical User Interface Packages"
    687              >next</a> |</li>
    688         <li class="right" >
    689           <a href="turtle.html" title="24.5. turtle  Turtle graphics for Tk"
    690              >previous</a> |</li>
    691         <li><img src="../_static/py.png" alt=""
    692                  style="vertical-align: middle; margin-top: -1px"/></li>
    693         <li><a href="https://www.python.org/">Python</a> &raquo;</li>
    694         <li>
    695           <a href="../index.html">Python 2.7.12 documentation</a> &raquo;
    696         </li>
    697 
    698           <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &raquo;</li>
    699           <li class="nav-item nav-item-2"><a href="tk.html" >24. Graphical User Interfaces with Tk</a> &raquo;</li>
    700       </ul>
    701     </div>
    702     <div class="footer">
    703     &copy; <a href="../copyright.html">Copyright</a> 1990-2016, Python Software Foundation.
    704     <br />
    705     The Python Software Foundation is a non-profit corporation.
    706     <a href="https://www.python.org/psf/donations/">Please donate.</a>
    707     <br />
    708     Last updated on Sep 12, 2016.
    709     <a href="../bugs.html">Found a bug</a>?
    710     <br />
    711     Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.3.6.
    712     </div>
    713 
    714   </body>
    715 </html>
    716