{"id":85,"date":"2019-01-15T23:24:54","date_gmt":"2019-01-15T23:24:54","guid":{"rendered":"https:\/\/courses.lumenlearning.com\/suny-albany-programmingforproblemsolving-v2\/back-matter\/appendix-a-python-on-your-computer\/"},"modified":"2019-01-28T19:07:11","modified_gmt":"2019-01-28T19:07:11","slug":"appendix-a-python-on-your-computer","status":"publish","type":"back-matter","link":"https:\/\/courses.lumenlearning.com\/suny-albany-programmingforproblemsolving-v2\/back-matter\/appendix-a-python-on-your-computer\/","title":{"raw":"Appendix A: Python on your Computer","rendered":"Appendix A: Python on your Computer"},"content":{"raw":"\n<div class=\"appendix-a:-python-on-your-computer\">\n<p class=\"import-Normal\">This Appendix will cover how to set up Python 3 and introduce you to IDLE, the Python development environment we will be using throughout this book.[footnote]based on material from https:\/\/www.python.org\/[\/footnote]\n<h1>Installing Python 3 and IDLE<span class=\"import-FootnoteReference\"><\/span><\/h1>\n<p class=\"import-Normal\">Installing Python is generally easy, and nowadays many Linux and UNIX distributions include a recent Python. Even some Windows computers (notably those from HP) now come with Python already installed.<\/p>\n[caption id=\"\" align=\"alignright\" width=\"382\"]<img src=\"https:\/\/s3-us-west-2.amazonaws.com\/courses-images\/wp-content\/uploads\/sites\/3976\/2019\/01\/15232453\/image50.jpg\" alt=\"image\" width=\"382\" height=\"242\" class=\"\"> Figure 49: Python Downloads Page[\/caption]\n<p class=\"import-Normal\">With that said, first of all check that you don't already have Python installed by entering <strong>python<\/strong> in a command line window. If you see a response from a Python interpreter it will include a version number in its initial display. Generally any version of Python 3 will suffice.<\/p>\n<p class=\"import-Normal\">If you need to install the Python 3 interpreter and IDLE software (IDE), you may as well download the most recent stable version. This is the one with the highest number that isn't marked as an alpha or beta release. Please see the Python downloads page, <a class=\"rId101\"><span class=\"import-Hyperlink\">https:\/\/www.python.org\/downloads\/<\/span><\/a> , for the most up to date versions of Python 3. They are available via the yellow download buttons on that page. For all downloads note the directory where the files will be saved to!<\/p>\n<ul>\n<li>If you're running Windows: the most stable Windows downloads are available from the Python for Windows page, <a class=\"rId102\"><span class=\"import-Hyperlink\">https:\/\/www.python.org\/downloads\/windows\/<\/span><\/a> .<\/li>\n<li>If you're running Windows XP: a complete guide to installing <em>ActivePython<\/em> is at Python on XP: 7 Minutes To \"Hello World!\", <a class=\"rId103\"><span class=\"import-Hyperlink\">http:\/\/dooling.com\/index.php\/2006\/03\/14\/python-on-xp-7-minutes-to-hello-world\/<\/span><\/a> . <em>ShowMeDo<\/em> (<a class=\"rId104\"><span class=\"import-Hyperlink\">https:\/\/wiki.python.org\/moin\/ShowMeDo<\/span><\/a> ) has two videos for downloading (<a class=\"rId105\"><span class=\"import-Hyperlink\">http:\/\/showmedo.com\/videos\/series?name=pythonOzsvaldPyNewbieSeries<\/span><\/a> ), installing and getting started with Python on a Windows XP machine - this series talks you through the Python, <em>ActivePython<\/em> and <em>SciPy<\/em> distributions.<\/li>\n<li>If you are using a Mac, see the Python for Mac OS X page, <a class=\"rId106\"><span class=\"import-Hyperlink\">https:\/\/www.python.org\/downloads\/mac-osx\/<\/span><\/a> . MacOS 10.2 (Jaguar), 10.3 (Panther), 10.4 (Tiger) and 10.5 (Leopard) already include various versions of Python.<\/li>\n<\/ul>\n<p class=\"import-Normal\">Once installed you should be all set to start using the Python development environment (IDLE) on your computer.<\/p>\n<h1>Using Python and its IDE&nbsp;<span class=\"import-FootnoteReference\"><\/span><\/h1>\n<p class=\"import-Normal\">IDLE is Python\u2019s Integrated Development and Learning Environment (IDE) and is included as part of the Python Standard Library which is distributed with Python 3. [footnote]Based on material from https:\/\/docs.python.org\/3\/library\/idle.html[\/footnote] IDLE is the standard Python development environment. Its name is an acronym of \"<strong>I<\/strong>ntegrated <strong>D<\/strong>eve<strong>L<\/strong>opment <strong>E<\/strong>nvironment\". It works well on both Unix and Windows platforms.<\/p>\n<p class=\"import-Normal\">It has a Python Shell window, which gives you access to the Python interactive mode. It also has a file editor that lets you create and edit existing Python source files.<\/p>\n<p class=\"import-NormalWeb\">IDLE\u2019s menus dynamically change based on which window is currently selected. Each menu documented below indicates which window type it is associated with.<\/p>\n<h2>File menu (Shell and Editor)<\/h2>\n<p class=\"import-Normal\"><strong>New File<\/strong>\n<p class=\"import-Normal\">Create a new file editing window.<\/p>\n<p class=\"import-Normal\"><strong>Open\u2026<\/strong>\n<p class=\"import-Normal\">Open an existing file with an Open dialog.<\/p>\n<p class=\"import-Normal\"><strong>Recent Files<\/strong>\n<p class=\"import-Normal\">Open a list of recent files. Click one to open it.<\/p>\n<p class=\"import-Normal\"><strong>Open Module\u2026<\/strong>\n<p class=\"import-Normal\">Open an existing module (searches sys.path).<\/p>\n<p class=\"import-Normal\"><strong>Class Browser<\/strong>\n<p class=\"import-Normal\">Show functions, classes, and methods in the current Editor file in a tree structure. In the shell, open a module first.<\/p>\n<p class=\"import-Normal\"><strong>Path Browser<\/strong>\n<p class=\"import-Normal\">Show sys.path directories, modules, functions, classes and methods in a tree structure.<\/p>\n<p class=\"import-Normal\"><strong>Save<\/strong>\n<p class=\"import-Normal\">Save the current window to the associated file, if there is one. Windows that have been changed since being opened or last saved have a * before and after the window title. If there is no associated file, do Save As instead.<\/p>\n<p class=\"import-Normal\"><strong>Save As\u2026<\/strong>\n<p class=\"import-Normal\">Save the current window with a Save As dialog. The file saved becomes the new associated file for the window.<\/p>\n<p class=\"import-Normal\"><strong>Save Copy As\u2026<\/strong>\n<p class=\"import-Normal\">Save the current window to different file without changing the associated file.<\/p>\n<p class=\"import-Normal\"><strong>Print Window<\/strong>\n<p class=\"import-Normal\">Print the current window to the default printer.<\/p>\n<p class=\"import-Normal\"><strong>Close<\/strong>\n<p class=\"import-Normal\">Close the current window (ask to save if unsaved).<\/p>\n<p class=\"import-Normal\"><strong>Exit<\/strong>\n<p class=\"import-Normal\">Close all windows and quit IDLE (ask to save unsaved windows).<\/p>\n<h2>Edit menu (Shell and Editor)<\/h2>\n<p class=\"import-Normal\"><strong>Undo<\/strong>\n<p class=\"import-Normal\">Undo the last change to the current window. A maximum of 1000 changes may be undone.<\/p>\n<p class=\"import-Normal\"><strong>Redo<\/strong>\n<p class=\"import-Normal\">Redo the last undone change to the current window.<\/p>\n<p class=\"import-Normal\"><strong>Cut<\/strong>\n<p class=\"import-Normal\">Copy selection into the system-wide clipboard; then delete the selection.<\/p>\n<p class=\"import-Normal\"><strong>Copy<\/strong>\n<p class=\"import-Normal\">Copy selection into the system-wide clipboard.<\/p>\n<p class=\"import-Normal\"><strong>Paste<\/strong>\n<p class=\"import-Normal\">Insert contents of the system-wide clipboard into the current window.<\/p>\n<p class=\"import-Normal\">The clipboard functions are also available in context menus.<\/p>\n<p class=\"import-Normal\"><strong>Select All<\/strong>\n<p class=\"import-Normal\">Select the entire contents of the current window.<\/p>\n<p class=\"import-Normal\"><strong>Find\u2026<\/strong>\n<p class=\"import-Normal\">Open a search dialog with many options<\/p>\n<p class=\"import-Normal\"><strong>Find Again<\/strong>\n<p class=\"import-Normal\">Repeat the last search, if there is one.<\/p>\n<p class=\"import-Normal\"><strong>Find Selection<\/strong>\n<p class=\"import-Normal\">Search for the currently selected string, if there is one.<\/p>\n<p class=\"import-Normal\"><strong>Find in Files\u2026<\/strong>\n<p class=\"import-Normal\">Open a file search dialog. Put results in a new output window.<\/p>\n<p class=\"import-Normal\"><strong>Replace\u2026<\/strong>\n<p class=\"import-Normal\">Open a search-and-replace dialog.<\/p>\n<p class=\"import-Normal\"><strong>Go to Line<\/strong>\n<p class=\"import-Normal\">Move cursor to the line number requested and make that line visible.<\/p>\n<p class=\"import-Normal\"><strong>Show Completions<\/strong>\n<p class=\"import-Normal\">Open a scrollable list allowing selection of keywords and attributes. See Completions in the Tips sections below.<\/p>\n<p class=\"import-Normal\"><strong>Expand Word<\/strong>\n<p class=\"import-Normal\">Expand a prefix you have typed to match a full word in the same window; repeat to get a different expansion.<\/p>\n<p class=\"import-Normal\"><strong>Show call tip<\/strong>\n<p class=\"import-Normal\">After an unclosed parenthesis for a function, open a small window with function parameter hints.<\/p>\n<p class=\"import-Normal\"><strong>Show surrounding parens<\/strong>\n<p class=\"import-Normal\">Highlight the surrounding parenthesis.<\/p>\n<h2>Format menu (Editor window only)<\/h2>\n<p class=\"import-Normal\"><strong>Indent Region<\/strong>\n<p class=\"import-Normal\">Shift selected lines right by the indent width (default 4 spaces).<\/p>\n<p class=\"import-Normal\"><strong>Dedent Region<\/strong>\n<p class=\"import-Normal\">Shift selected lines left by the indent width (default 4 spaces).<\/p>\n<p class=\"import-Normal\"><strong>Comment Out Region<\/strong>\n<p class=\"import-Normal\">Insert ## in front of selected lines.<\/p>\n<p class=\"import-Normal\"><strong>Uncomment Region<\/strong>\n<p class=\"import-Normal\">Remove leading # or ## from selected lines.<\/p>\n<p class=\"import-Normal\"><strong>Tabify Region<\/strong>\n<p class=\"import-Normal\">Turn leading stretches of spaces into tabs. (Note: We recommend using 4 space blocks to indent Python code.)<\/p>\n<p class=\"import-Normal\"><strong>Untabify Region<\/strong>\n<p class=\"import-Normal\">Turn all tabs into the correct number of spaces.<\/p>\n<p class=\"import-Normal\"><strong>Toggle Tabs<\/strong>\n<p class=\"import-Normal\">Open a dialog to switch between indenting with spaces and tabs.<\/p>\n<p class=\"import-Normal\"><strong>New Indent Width<\/strong>\n<p class=\"import-Normal\">Open a dialog to change indent width. The accepted default by the Python community is 4 spaces.<\/p>\n<p class=\"import-Normal\"><strong>Format Paragraph<\/strong>\n<p class=\"import-Normal\">Reformat the current blank-line-delimited paragraph in comment block or multiline string or selected line in a string. All lines in the paragraph will be formatted to less than N columns, where N defaults to 72.<\/p>\n<p class=\"import-Normal\"><strong>Strip trailing whitespace<\/strong>\n<p class=\"import-Normal\">Remove trailing space and other whitespace characters after the last non-whitespace character of a line by applying str.rstrip to each line, including lines within multiline strings.<\/p>\n<h2>Run menu (Editor window only)<\/h2>\n<p class=\"import-Normal\"><strong>Python Shell<\/strong>\n<p class=\"import-Normal\">Open or wake up the Python Shell window.<\/p>\n<p class=\"import-Normal\"><strong>Check Module<\/strong>\n<p class=\"import-Normal\">Check the syntax of the module currently open in the Editor window. If the module has not been saved IDLE will either prompt the user to save or autosave, as selected in the General tab of the Idle Settings dialog. If there is a syntax error, the approximate location is indicated in the Editor window.<\/p>\n<p class=\"import-Normal\"><strong>Run Module<\/strong>\n<p class=\"import-Normal\">Do Check Module (above). If no error, restart the shell to clean the environment, then execute the module. Output is displayed in the Shell window. Note that output requires use of print or write. When execution is complete, the Shell retains focus and displays a prompt. At this point, one may interactively explore the result of execution. This is similar to executing a file with python -i file at a command line.<\/p>\n<h2>Shell menu (Shell window only)<\/h2>\n<p class=\"import-Normal\"><strong>View Last Restart<\/strong>\n<p class=\"import-Normal\">Scroll the Shell window to the last shell restart.<\/p>\n<p class=\"import-Normal\"><strong>Restart Shell<\/strong>\n<p class=\"import-Normal\">Restart the Shell to clean the environment.<\/p>\n<p class=\"import-Normal\"><strong>Interrupt Execution<\/strong>\n<p class=\"import-Normal\">Stop a running program.<\/p>\n<h2>Debug menu (Shell window only)<\/h2>\n<p class=\"import-Normal\"><strong>Go to File\/Line<\/strong>\n<p class=\"import-Normal\">Look on the current line. with the cursor, and the line above for a filename and line number. If found, open the file if not already open, and show the line. Use this to view source lines referenced in an exception traceback and lines found by Find in Files. Also available in the context menu of the Shell window and Output windows.<\/p>\n<p class=\"import-Normal\"><strong>Debugger (toggle)<\/strong>\n<p class=\"import-Normal\">When activated, code entered in the Shell or run from an Editor will run under the debugger. In the Editor, breakpoints can be set with the context menu. This feature is still incomplete and somewhat experimental.<\/p>\n<p class=\"import-Normal\"><strong>Stack Viewer<\/strong>\n<p class=\"import-Normal\">Show the stack traceback of the last exception in a tree widget, with access to locals and globals.<\/p>\n<p class=\"import-Normal\"><strong>Auto-open Stack Viewer<\/strong>\n<p class=\"import-Normal\">Toggle automatically opening the stack viewer on an unhandled exception.<\/p>\n<h2>Options menu (Shell and Editor)<\/h2>\n<p class=\"import-Normal\"><strong>Configure IDLE<\/strong>\n<p class=\"import-Normal\">Open a configuration dialog and change preferences for the following: fonts, indentation, keybindings, text color themes, startup windows and size, additional help sources, and extensions (see below). On OS X, open the configuration dialog by selecting Preferences in the application menu. To use a new built-in color theme (IDLE Dark) with older IDLEs, save it as a new custom theme.<\/p>\n<p class=\"import-Normal\">Non-default user settings are saved in a .idlerc directory in the user\u2019s home directory. Problems caused by bad user configuration files are solved by editing or deleting one or more of the files in .idlerc.<\/p>\n<p class=\"import-Normal\">Code Context (toggle)(Editor Window only)<\/p>\n<p class=\"import-Normal\">Open a pane at the top of the edit window which shows the block context of the code which has scrolled above the top of the window.<\/p>\n<h2>Window menu (Shell and Editor)<\/h2>\n<p class=\"import-Normal\"><strong>Zoom Height<\/strong>\n<p class=\"import-Normal\">Toggles the window between normal size and maximum height. The initial size defaults to 40 lines by 80 chars unless changed on the General tab of the Configure IDLE dialog.<\/p>\n<p class=\"import-Normal\">The rest of this menu lists the names of all open windows; select one to bring it to the foreground (deiconifying it if necessary).<\/p>\n<h2>Help menu (Shell and Editor)<\/h2>\n<p class=\"import-Normal\"><strong>About IDLE<\/strong>\n<p class=\"import-Normal\">Display version, copyright, license, credits, and more.<\/p>\n<p class=\"import-Normal\"><strong>IDLE Help<\/strong>\n<p class=\"import-Normal\">Display a help file for IDLE detailing the menu options, basic editing and navigation, and other tips.<\/p>\n<p class=\"import-Normal\"><strong>Python Docs<\/strong>\n<p class=\"import-Normal\">Access local Python documentation, if installed, or start a web browser and open docs.python.org showing the latest Python documentation.<\/p>\n<p class=\"import-Normal\"><strong>Turtle Demo<\/strong>\n<p class=\"import-Normal\">Run the turtledemo module with example python code and turtle drawings.<\/p>\n<p class=\"import-Normal\">Additional help sources may be added here with the Configure IDLE dialog under the General tab.<\/p>\n<h2>Context Menus<\/h2>\n<p class=\"import-Normal\">Open a context menu by right-clicking in a window (Control-click on OS X). Context menus have the standard clipboard functions also on the Edit menu.<\/p>\n<p class=\"import-Normal\"><strong>Cut<\/strong>\n<p class=\"import-Normal\">Copy selection into the system-wide clipboard; then delete the selection.<\/p>\n<p class=\"import-Normal\"><strong>Copy<\/strong>\n<p class=\"import-Normal\">Copy selection into the system-wide clipboard.<\/p>\n<p class=\"import-Normal\"><strong>Paste<\/strong>\n<p class=\"import-Normal\">Insert contents of the system-wide clipboard into the current window.<\/p>\n<p class=\"import-Normal\">Editor windows also have breakpoint functions. Lines with a breakpoint set are specially marked. Breakpoints only have an effect when running under the debugger. Breakpoints for a file are saved in the user\u2019s .idlerc directory.<\/p>\n<p class=\"import-Normal\"><strong>Set Breakpoint<\/strong>\n<p class=\"import-Normal\">Set a breakpoint on the current line.<\/p>\n<p class=\"import-Normal\"><strong>Clear Breakpoint<\/strong>\n<p class=\"import-Normal\">Clear the breakpoint on that line.<\/p>\n<p class=\"import-Normal\">Shell and Output windows have the following.<\/p>\n<p class=\"import-Normal\"><strong>Go to file\/line<\/strong>\n<p class=\"import-Normal\">Same as in Debug menu.<\/p>\n<h2>Automatic indentation<\/h2>\n<p class=\"import-Normal\">After a block-opening statement, the next line is indented by 4 spaces (in the Python Shell window by one tab). After certain keywords (break, return etc.) the next line is dedented. In leading indentation, Backspace deletes up to 4 spaces if they are there. Tab inserts spaces (in the Python Shell window one tab), number depends on Indent width. Currently, tabs are restricted to four spaces due to Tcl\/Tk limitations.<\/p>\n<p class=\"import-Normal\">See also the indent\/dedent region commands in the edit menu.<\/p>\n<h2>Text colors<\/h2>\n<p class=\"import-Normal\">Idle defaults to black on white text, but colors text with special meanings. For the Shell, these are Shell output, Shell error, user output, and user error. For Python code, at the Shell prompt or in an editor, these are keywords, built-in class and function names, names following class and def, strings, and comments. For any text window, these are the cursor (when present), found text (when possible), and selected text.<\/p>\n<p class=\"import-Normal\">Text coloring is done in the background, so uncolorized text is occasionally visible. To change the color scheme, use the Configure IDLE dialog Highlighting tab. The marking of debugger breakpoint lines in the editor and text in pop-ups and dialogs is not user-configurable.<\/p>\n<\/div>\n\n","rendered":"<div class=\"appendix-a:-python-on-your-computer\">\n<p class=\"import-Normal\">This Appendix will cover how to set up Python 3 and introduce you to IDLE, the Python development environment we will be using throughout this book.<a class=\"footnote\" title=\"based on material from https:\/\/www.python.org\/\" id=\"return-footnote-85-1\" href=\"#footnote-85-1\" aria-label=\"Footnote 1\"><sup class=\"footnote\">[1]<\/sup><\/a>\n<\/p>\n<h1>Installing Python 3 and IDLE<span class=\"import-FootnoteReference\"><\/span><\/h1>\n<p class=\"import-Normal\">Installing Python is generally easy, and nowadays many Linux and UNIX distributions include a recent Python. Even some Windows computers (notably those from HP) now come with Python already installed.<\/p>\n<div style=\"width: 392px\" class=\"wp-caption alignright\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/s3-us-west-2.amazonaws.com\/courses-images\/wp-content\/uploads\/sites\/3976\/2019\/01\/15232453\/image50.jpg\" alt=\"image\" width=\"382\" height=\"242\" class=\"\" \/><\/p>\n<p class=\"wp-caption-text\">Figure 49: Python Downloads Page<\/p>\n<\/div>\n<p class=\"import-Normal\">With that said, first of all check that you don&#8217;t already have Python installed by entering <strong>python<\/strong> in a command line window. If you see a response from a Python interpreter it will include a version number in its initial display. Generally any version of Python 3 will suffice.<\/p>\n<p class=\"import-Normal\">If you need to install the Python 3 interpreter and IDLE software (IDE), you may as well download the most recent stable version. This is the one with the highest number that isn&#8217;t marked as an alpha or beta release. Please see the Python downloads page, <a class=\"rId101\"><span class=\"import-Hyperlink\">https:\/\/www.python.org\/downloads\/<\/span><\/a> , for the most up to date versions of Python 3. They are available via the yellow download buttons on that page. For all downloads note the directory where the files will be saved to!<\/p>\n<ul>\n<li>If you&#8217;re running Windows: the most stable Windows downloads are available from the Python for Windows page, <a class=\"rId102\"><span class=\"import-Hyperlink\">https:\/\/www.python.org\/downloads\/windows\/<\/span><\/a> .<\/li>\n<li>If you&#8217;re running Windows XP: a complete guide to installing <em>ActivePython<\/em> is at Python on XP: 7 Minutes To &#8220;Hello World!&#8221;, <a class=\"rId103\"><span class=\"import-Hyperlink\">http:\/\/dooling.com\/index.php\/2006\/03\/14\/python-on-xp-7-minutes-to-hello-world\/<\/span><\/a> . <em>ShowMeDo<\/em> (<a class=\"rId104\"><span class=\"import-Hyperlink\">https:\/\/wiki.python.org\/moin\/ShowMeDo<\/span><\/a> ) has two videos for downloading (<a class=\"rId105\"><span class=\"import-Hyperlink\">http:\/\/showmedo.com\/videos\/series?name=pythonOzsvaldPyNewbieSeries<\/span><\/a> ), installing and getting started with Python on a Windows XP machine &#8211; this series talks you through the Python, <em>ActivePython<\/em> and <em>SciPy<\/em> distributions.<\/li>\n<li>If you are using a Mac, see the Python for Mac OS X page, <a class=\"rId106\"><span class=\"import-Hyperlink\">https:\/\/www.python.org\/downloads\/mac-osx\/<\/span><\/a> . MacOS 10.2 (Jaguar), 10.3 (Panther), 10.4 (Tiger) and 10.5 (Leopard) already include various versions of Python.<\/li>\n<\/ul>\n<p class=\"import-Normal\">Once installed you should be all set to start using the Python development environment (IDLE) on your computer.<\/p>\n<h1>Using Python and its IDE&nbsp;<span class=\"import-FootnoteReference\"><\/span><\/h1>\n<p class=\"import-Normal\">IDLE is Python\u2019s Integrated Development and Learning Environment (IDE) and is included as part of the Python Standard Library which is distributed with Python 3. <a class=\"footnote\" title=\"Based on material from https:\/\/docs.python.org\/3\/library\/idle.html\" id=\"return-footnote-85-2\" href=\"#footnote-85-2\" aria-label=\"Footnote 2\"><sup class=\"footnote\">[2]<\/sup><\/a> IDLE is the standard Python development environment. Its name is an acronym of &#8220;<strong>I<\/strong>ntegrated <strong>D<\/strong>eve<strong>L<\/strong>opment <strong>E<\/strong>nvironment&#8221;. It works well on both Unix and Windows platforms.<\/p>\n<p class=\"import-Normal\">It has a Python Shell window, which gives you access to the Python interactive mode. It also has a file editor that lets you create and edit existing Python source files.<\/p>\n<p class=\"import-NormalWeb\">IDLE\u2019s menus dynamically change based on which window is currently selected. Each menu documented below indicates which window type it is associated with.<\/p>\n<h2>File menu (Shell and Editor)<\/h2>\n<p class=\"import-Normal\"><strong>New File<\/strong>\n<\/p>\n<p class=\"import-Normal\">Create a new file editing window.<\/p>\n<p class=\"import-Normal\"><strong>Open\u2026<\/strong>\n<\/p>\n<p class=\"import-Normal\">Open an existing file with an Open dialog.<\/p>\n<p class=\"import-Normal\"><strong>Recent Files<\/strong>\n<\/p>\n<p class=\"import-Normal\">Open a list of recent files. Click one to open it.<\/p>\n<p class=\"import-Normal\"><strong>Open Module\u2026<\/strong>\n<\/p>\n<p class=\"import-Normal\">Open an existing module (searches sys.path).<\/p>\n<p class=\"import-Normal\"><strong>Class Browser<\/strong>\n<\/p>\n<p class=\"import-Normal\">Show functions, classes, and methods in the current Editor file in a tree structure. In the shell, open a module first.<\/p>\n<p class=\"import-Normal\"><strong>Path Browser<\/strong>\n<\/p>\n<p class=\"import-Normal\">Show sys.path directories, modules, functions, classes and methods in a tree structure.<\/p>\n<p class=\"import-Normal\"><strong>Save<\/strong>\n<\/p>\n<p class=\"import-Normal\">Save the current window to the associated file, if there is one. Windows that have been changed since being opened or last saved have a * before and after the window title. If there is no associated file, do Save As instead.<\/p>\n<p class=\"import-Normal\"><strong>Save As\u2026<\/strong>\n<\/p>\n<p class=\"import-Normal\">Save the current window with a Save As dialog. The file saved becomes the new associated file for the window.<\/p>\n<p class=\"import-Normal\"><strong>Save Copy As\u2026<\/strong>\n<\/p>\n<p class=\"import-Normal\">Save the current window to different file without changing the associated file.<\/p>\n<p class=\"import-Normal\"><strong>Print Window<\/strong>\n<\/p>\n<p class=\"import-Normal\">Print the current window to the default printer.<\/p>\n<p class=\"import-Normal\"><strong>Close<\/strong>\n<\/p>\n<p class=\"import-Normal\">Close the current window (ask to save if unsaved).<\/p>\n<p class=\"import-Normal\"><strong>Exit<\/strong>\n<\/p>\n<p class=\"import-Normal\">Close all windows and quit IDLE (ask to save unsaved windows).<\/p>\n<h2>Edit menu (Shell and Editor)<\/h2>\n<p class=\"import-Normal\"><strong>Undo<\/strong>\n<\/p>\n<p class=\"import-Normal\">Undo the last change to the current window. A maximum of 1000 changes may be undone.<\/p>\n<p class=\"import-Normal\"><strong>Redo<\/strong>\n<\/p>\n<p class=\"import-Normal\">Redo the last undone change to the current window.<\/p>\n<p class=\"import-Normal\"><strong>Cut<\/strong>\n<\/p>\n<p class=\"import-Normal\">Copy selection into the system-wide clipboard; then delete the selection.<\/p>\n<p class=\"import-Normal\"><strong>Copy<\/strong>\n<\/p>\n<p class=\"import-Normal\">Copy selection into the system-wide clipboard.<\/p>\n<p class=\"import-Normal\"><strong>Paste<\/strong>\n<\/p>\n<p class=\"import-Normal\">Insert contents of the system-wide clipboard into the current window.<\/p>\n<p class=\"import-Normal\">The clipboard functions are also available in context menus.<\/p>\n<p class=\"import-Normal\"><strong>Select All<\/strong>\n<\/p>\n<p class=\"import-Normal\">Select the entire contents of the current window.<\/p>\n<p class=\"import-Normal\"><strong>Find\u2026<\/strong>\n<\/p>\n<p class=\"import-Normal\">Open a search dialog with many options<\/p>\n<p class=\"import-Normal\"><strong>Find Again<\/strong>\n<\/p>\n<p class=\"import-Normal\">Repeat the last search, if there is one.<\/p>\n<p class=\"import-Normal\"><strong>Find Selection<\/strong>\n<\/p>\n<p class=\"import-Normal\">Search for the currently selected string, if there is one.<\/p>\n<p class=\"import-Normal\"><strong>Find in Files\u2026<\/strong>\n<\/p>\n<p class=\"import-Normal\">Open a file search dialog. Put results in a new output window.<\/p>\n<p class=\"import-Normal\"><strong>Replace\u2026<\/strong>\n<\/p>\n<p class=\"import-Normal\">Open a search-and-replace dialog.<\/p>\n<p class=\"import-Normal\"><strong>Go to Line<\/strong>\n<\/p>\n<p class=\"import-Normal\">Move cursor to the line number requested and make that line visible.<\/p>\n<p class=\"import-Normal\"><strong>Show Completions<\/strong>\n<\/p>\n<p class=\"import-Normal\">Open a scrollable list allowing selection of keywords and attributes. See Completions in the Tips sections below.<\/p>\n<p class=\"import-Normal\"><strong>Expand Word<\/strong>\n<\/p>\n<p class=\"import-Normal\">Expand a prefix you have typed to match a full word in the same window; repeat to get a different expansion.<\/p>\n<p class=\"import-Normal\"><strong>Show call tip<\/strong>\n<\/p>\n<p class=\"import-Normal\">After an unclosed parenthesis for a function, open a small window with function parameter hints.<\/p>\n<p class=\"import-Normal\"><strong>Show surrounding parens<\/strong>\n<\/p>\n<p class=\"import-Normal\">Highlight the surrounding parenthesis.<\/p>\n<h2>Format menu (Editor window only)<\/h2>\n<p class=\"import-Normal\"><strong>Indent Region<\/strong>\n<\/p>\n<p class=\"import-Normal\">Shift selected lines right by the indent width (default 4 spaces).<\/p>\n<p class=\"import-Normal\"><strong>Dedent Region<\/strong>\n<\/p>\n<p class=\"import-Normal\">Shift selected lines left by the indent width (default 4 spaces).<\/p>\n<p class=\"import-Normal\"><strong>Comment Out Region<\/strong>\n<\/p>\n<p class=\"import-Normal\">Insert ## in front of selected lines.<\/p>\n<p class=\"import-Normal\"><strong>Uncomment Region<\/strong>\n<\/p>\n<p class=\"import-Normal\">Remove leading # or ## from selected lines.<\/p>\n<p class=\"import-Normal\"><strong>Tabify Region<\/strong>\n<\/p>\n<p class=\"import-Normal\">Turn leading stretches of spaces into tabs. (Note: We recommend using 4 space blocks to indent Python code.)<\/p>\n<p class=\"import-Normal\"><strong>Untabify Region<\/strong>\n<\/p>\n<p class=\"import-Normal\">Turn all tabs into the correct number of spaces.<\/p>\n<p class=\"import-Normal\"><strong>Toggle Tabs<\/strong>\n<\/p>\n<p class=\"import-Normal\">Open a dialog to switch between indenting with spaces and tabs.<\/p>\n<p class=\"import-Normal\"><strong>New Indent Width<\/strong>\n<\/p>\n<p class=\"import-Normal\">Open a dialog to change indent width. The accepted default by the Python community is 4 spaces.<\/p>\n<p class=\"import-Normal\"><strong>Format Paragraph<\/strong>\n<\/p>\n<p class=\"import-Normal\">Reformat the current blank-line-delimited paragraph in comment block or multiline string or selected line in a string. All lines in the paragraph will be formatted to less than N columns, where N defaults to 72.<\/p>\n<p class=\"import-Normal\"><strong>Strip trailing whitespace<\/strong>\n<\/p>\n<p class=\"import-Normal\">Remove trailing space and other whitespace characters after the last non-whitespace character of a line by applying str.rstrip to each line, including lines within multiline strings.<\/p>\n<h2>Run menu (Editor window only)<\/h2>\n<p class=\"import-Normal\"><strong>Python Shell<\/strong>\n<\/p>\n<p class=\"import-Normal\">Open or wake up the Python Shell window.<\/p>\n<p class=\"import-Normal\"><strong>Check Module<\/strong>\n<\/p>\n<p class=\"import-Normal\">Check the syntax of the module currently open in the Editor window. If the module has not been saved IDLE will either prompt the user to save or autosave, as selected in the General tab of the Idle Settings dialog. If there is a syntax error, the approximate location is indicated in the Editor window.<\/p>\n<p class=\"import-Normal\"><strong>Run Module<\/strong>\n<\/p>\n<p class=\"import-Normal\">Do Check Module (above). If no error, restart the shell to clean the environment, then execute the module. Output is displayed in the Shell window. Note that output requires use of print or write. When execution is complete, the Shell retains focus and displays a prompt. At this point, one may interactively explore the result of execution. This is similar to executing a file with python -i file at a command line.<\/p>\n<h2>Shell menu (Shell window only)<\/h2>\n<p class=\"import-Normal\"><strong>View Last Restart<\/strong>\n<\/p>\n<p class=\"import-Normal\">Scroll the Shell window to the last shell restart.<\/p>\n<p class=\"import-Normal\"><strong>Restart Shell<\/strong>\n<\/p>\n<p class=\"import-Normal\">Restart the Shell to clean the environment.<\/p>\n<p class=\"import-Normal\"><strong>Interrupt Execution<\/strong>\n<\/p>\n<p class=\"import-Normal\">Stop a running program.<\/p>\n<h2>Debug menu (Shell window only)<\/h2>\n<p class=\"import-Normal\"><strong>Go to File\/Line<\/strong>\n<\/p>\n<p class=\"import-Normal\">Look on the current line. with the cursor, and the line above for a filename and line number. If found, open the file if not already open, and show the line. Use this to view source lines referenced in an exception traceback and lines found by Find in Files. Also available in the context menu of the Shell window and Output windows.<\/p>\n<p class=\"import-Normal\"><strong>Debugger (toggle)<\/strong>\n<\/p>\n<p class=\"import-Normal\">When activated, code entered in the Shell or run from an Editor will run under the debugger. In the Editor, breakpoints can be set with the context menu. This feature is still incomplete and somewhat experimental.<\/p>\n<p class=\"import-Normal\"><strong>Stack Viewer<\/strong>\n<\/p>\n<p class=\"import-Normal\">Show the stack traceback of the last exception in a tree widget, with access to locals and globals.<\/p>\n<p class=\"import-Normal\"><strong>Auto-open Stack Viewer<\/strong>\n<\/p>\n<p class=\"import-Normal\">Toggle automatically opening the stack viewer on an unhandled exception.<\/p>\n<h2>Options menu (Shell and Editor)<\/h2>\n<p class=\"import-Normal\"><strong>Configure IDLE<\/strong>\n<\/p>\n<p class=\"import-Normal\">Open a configuration dialog and change preferences for the following: fonts, indentation, keybindings, text color themes, startup windows and size, additional help sources, and extensions (see below). On OS X, open the configuration dialog by selecting Preferences in the application menu. To use a new built-in color theme (IDLE Dark) with older IDLEs, save it as a new custom theme.<\/p>\n<p class=\"import-Normal\">Non-default user settings are saved in a .idlerc directory in the user\u2019s home directory. Problems caused by bad user configuration files are solved by editing or deleting one or more of the files in .idlerc.<\/p>\n<p class=\"import-Normal\">Code Context (toggle)(Editor Window only)<\/p>\n<p class=\"import-Normal\">Open a pane at the top of the edit window which shows the block context of the code which has scrolled above the top of the window.<\/p>\n<h2>Window menu (Shell and Editor)<\/h2>\n<p class=\"import-Normal\"><strong>Zoom Height<\/strong>\n<\/p>\n<p class=\"import-Normal\">Toggles the window between normal size and maximum height. The initial size defaults to 40 lines by 80 chars unless changed on the General tab of the Configure IDLE dialog.<\/p>\n<p class=\"import-Normal\">The rest of this menu lists the names of all open windows; select one to bring it to the foreground (deiconifying it if necessary).<\/p>\n<h2>Help menu (Shell and Editor)<\/h2>\n<p class=\"import-Normal\"><strong>About IDLE<\/strong>\n<\/p>\n<p class=\"import-Normal\">Display version, copyright, license, credits, and more.<\/p>\n<p class=\"import-Normal\"><strong>IDLE Help<\/strong>\n<\/p>\n<p class=\"import-Normal\">Display a help file for IDLE detailing the menu options, basic editing and navigation, and other tips.<\/p>\n<p class=\"import-Normal\"><strong>Python Docs<\/strong>\n<\/p>\n<p class=\"import-Normal\">Access local Python documentation, if installed, or start a web browser and open docs.python.org showing the latest Python documentation.<\/p>\n<p class=\"import-Normal\"><strong>Turtle Demo<\/strong>\n<\/p>\n<p class=\"import-Normal\">Run the turtledemo module with example python code and turtle drawings.<\/p>\n<p class=\"import-Normal\">Additional help sources may be added here with the Configure IDLE dialog under the General tab.<\/p>\n<h2>Context Menus<\/h2>\n<p class=\"import-Normal\">Open a context menu by right-clicking in a window (Control-click on OS X). Context menus have the standard clipboard functions also on the Edit menu.<\/p>\n<p class=\"import-Normal\"><strong>Cut<\/strong>\n<\/p>\n<p class=\"import-Normal\">Copy selection into the system-wide clipboard; then delete the selection.<\/p>\n<p class=\"import-Normal\"><strong>Copy<\/strong>\n<\/p>\n<p class=\"import-Normal\">Copy selection into the system-wide clipboard.<\/p>\n<p class=\"import-Normal\"><strong>Paste<\/strong>\n<\/p>\n<p class=\"import-Normal\">Insert contents of the system-wide clipboard into the current window.<\/p>\n<p class=\"import-Normal\">Editor windows also have breakpoint functions. Lines with a breakpoint set are specially marked. Breakpoints only have an effect when running under the debugger. Breakpoints for a file are saved in the user\u2019s .idlerc directory.<\/p>\n<p class=\"import-Normal\"><strong>Set Breakpoint<\/strong>\n<\/p>\n<p class=\"import-Normal\">Set a breakpoint on the current line.<\/p>\n<p class=\"import-Normal\"><strong>Clear Breakpoint<\/strong>\n<\/p>\n<p class=\"import-Normal\">Clear the breakpoint on that line.<\/p>\n<p class=\"import-Normal\">Shell and Output windows have the following.<\/p>\n<p class=\"import-Normal\"><strong>Go to file\/line<\/strong>\n<\/p>\n<p class=\"import-Normal\">Same as in Debug menu.<\/p>\n<h2>Automatic indentation<\/h2>\n<p class=\"import-Normal\">After a block-opening statement, the next line is indented by 4 spaces (in the Python Shell window by one tab). After certain keywords (break, return etc.) the next line is dedented. In leading indentation, Backspace deletes up to 4 spaces if they are there. Tab inserts spaces (in the Python Shell window one tab), number depends on Indent width. Currently, tabs are restricted to four spaces due to Tcl\/Tk limitations.<\/p>\n<p class=\"import-Normal\">See also the indent\/dedent region commands in the edit menu.<\/p>\n<h2>Text colors<\/h2>\n<p class=\"import-Normal\">Idle defaults to black on white text, but colors text with special meanings. For the Shell, these are Shell output, Shell error, user output, and user error. For Python code, at the Shell prompt or in an editor, these are keywords, built-in class and function names, names following class and def, strings, and comments. For any text window, these are the cursor (when present), found text (when possible), and selected text.<\/p>\n<p class=\"import-Normal\">Text coloring is done in the background, so uncolorized text is occasionally visible. To change the color scheme, use the Configure IDLE dialog Highlighting tab. The marking of debugger breakpoint lines in the editor and text in pop-ups and dialogs is not user-configurable.<\/p>\n<\/div>\n<hr class=\"before-footnotes clear\" \/><div class=\"footnotes\"><ol><li id=\"footnote-85-1\">based on material from https:\/\/www.python.org\/ <a href=\"#return-footnote-85-1\" class=\"return-footnote\" aria-label=\"Return to footnote 1\">&crarr;<\/a><\/li><li id=\"footnote-85-2\">Based on material from https:\/\/docs.python.org\/3\/library\/idle.html <a href=\"#return-footnote-85-2\" class=\"return-footnote\" aria-label=\"Return to footnote 2\">&crarr;<\/a><\/li><\/ol><\/div>","protected":false},"author":23485,"menu_order":1,"template":"","meta":{"_candela_citation":"[]","CANDELA_OUTCOMES_GUID":"","pb_show_title":"on","pb_short_title":"","pb_subtitle":"","pb_authors":[],"pb_section_license":""},"back-matter-type":[],"contributor":[],"license":[],"class_list":["post-85","back-matter","type-back-matter","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/courses.lumenlearning.com\/suny-albany-programmingforproblemsolving-v2\/wp-json\/pressbooks\/v2\/back-matter\/85","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/courses.lumenlearning.com\/suny-albany-programmingforproblemsolving-v2\/wp-json\/pressbooks\/v2\/back-matter"}],"about":[{"href":"https:\/\/courses.lumenlearning.com\/suny-albany-programmingforproblemsolving-v2\/wp-json\/wp\/v2\/types\/back-matter"}],"author":[{"embeddable":true,"href":"https:\/\/courses.lumenlearning.com\/suny-albany-programmingforproblemsolving-v2\/wp-json\/wp\/v2\/users\/23485"}],"version-history":[{"count":1,"href":"https:\/\/courses.lumenlearning.com\/suny-albany-programmingforproblemsolving-v2\/wp-json\/pressbooks\/v2\/back-matter\/85\/revisions"}],"predecessor-version":[{"id":107,"href":"https:\/\/courses.lumenlearning.com\/suny-albany-programmingforproblemsolving-v2\/wp-json\/pressbooks\/v2\/back-matter\/85\/revisions\/107"}],"metadata":[{"href":"https:\/\/courses.lumenlearning.com\/suny-albany-programmingforproblemsolving-v2\/wp-json\/pressbooks\/v2\/back-matter\/85\/metadata\/"}],"wp:attachment":[{"href":"https:\/\/courses.lumenlearning.com\/suny-albany-programmingforproblemsolving-v2\/wp-json\/wp\/v2\/media?parent=85"}],"wp:term":[{"taxonomy":"back-matter-type","embeddable":true,"href":"https:\/\/courses.lumenlearning.com\/suny-albany-programmingforproblemsolving-v2\/wp-json\/pressbooks\/v2\/back-matter-type?post=85"},{"taxonomy":"contributor","embeddable":true,"href":"https:\/\/courses.lumenlearning.com\/suny-albany-programmingforproblemsolving-v2\/wp-json\/wp\/v2\/contributor?post=85"},{"taxonomy":"license","embeddable":true,"href":"https:\/\/courses.lumenlearning.com\/suny-albany-programmingforproblemsolving-v2\/wp-json\/wp\/v2\/license?post=85"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}