12.07.2015 Views

Is Python a

Is Python a

Is Python a

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

start occasionally on some Windows machines). If you run into such connectionerrors, it’s always possible to start IDLE with a system command line that forces itto run in single-process mode, and therefore avoids communication issues: its -ncommand-line flag forces this mode. On Windows, for example, start a CommandPrompt window, and run the system command line idle.py –n from withinthe directory C:\<strong>Python</strong>25\Lib\idlelib (cd there first if needed).• Beware of some IDLE usability features. IDLE does much to make life easier forbeginners, but some of its tricks won’t apply outside the IDLE GUI. Forinstance, IDLE runs your script in IDLE’s environment, so variables in your codeshow up automatically in the IDLE interactive session—you don’t always needto run import commands to access names at the top level of files you’ve alreadyrun. This can be handy, but it can also be confusing, because outside the IDLEenvironment, names must always be imported from files to be used.Advanced IDLE ToolsBesides the basic edit and run functions, IDLE provides more advanced features,including a point-and-click program debugger, and an object browser. The IDLEdebugger is enabled via the Debug menu, and the object browser via the File menu.The browser allows you to navigate through the module search path to files andobjects in files; clicking on a file or object opens the corresponding source in a textedit window.IDLE debugging is initiated by selecting the Debug ➝ Debugger menu option in themain window, and then starting your script by selecting the Run ➝ Run Moduleoption in the text edit window; once the debugger is enabled, you can set breakpointsin your code that stop its execution by right-clicking on lines in the text editwindows, show variable values, and so on. You can also watch program executionwhen debugging—the current line of code is noted as you step through your code.For simpler debugging operations, you can also right-click with your mouse on thetext of an error message to quickly jump to the line of code where the erroroccurred—a trick that makes it simple and fast to repair and run again. In addition,IDLE’s text editor offers a large collection of programmer-friendly tools, includingautomatic indentation, advanced text and file search operations, and more. BecauseIDLE uses intuitive GUI interactions, you should experiment with the system live toget a feel for its other tools.Other IDEsBecause IDLE is free, portable, and a standard part of <strong>Python</strong>, it’s a nice first developmenttool to become familiar with if you want to use an IDE at all. Again, I recommendthat you use IDLE for this book’s exercises if you’re just starting out, unless you are54 | Chapter 3: How You Run Programs

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!