code--but when you make mistake in python programyou get very useful and readable error message (you'll get to see some soonif you haven' alreadyif you already know pythonand especially for your own codethis is often enough --read the error messageand go fix the tagged line and file for manythis is debugging in python it may not always be ideal for larger systems you didn' writethough insert print statements probably the main way that python programmers debug their code (and the way that debug python codeis to insert print statements and run again because python runs immediately after changesthis is usually the quickest way to get more information than error messages provide the print statements don' have to be sophisticated-- simple " am hereor display of variable values is usually enough to provide the context you need just remember to delete or comment out ( add beforethe debugging prints before you ship your codeuse ide gui debuggers for larger systems you didn' writeand for beginners who want to trace code in more detailmost python development guis have some sort of point-and-click debugging support idle has debugger toobut it doesn' appear to be used very often in practice--perhaps because it has no command lineor perhaps because adding print statements is usually quicker than setting up gui debugging session to learn moresee idle' helpor simply try it on your ownits basic interface is described in the section "advanced idle toolson page other idessuch as eclipsenetbeanskomodoand wing ideoffer advanced point-and-click debuggers as wellsee their documentation if you use them use the pdb command-line debugger for ultimate controlpython comes with source code debugger named pdbavailable as module in python' standard library in pdbyou type commands to step line by linedisplay variablesset and clear breakpointscontinue to breakpoint or errorand so on you can launch pdb interactively by importing itor as top-level script either waybecause you can type commands to control the sessionit provides powerful debugging tool pdb also includes postmortem function (pdb pm()that you can run after an exception occursto get information from the time of the error see the python library manual and for more details on pdband appendix for an example or running pdb as script with python' - command argument use python' - command-line argument short of adding prints or running under pdbyou can still see what went wrong on errors if you run your script from command line and pass - argument between python and the name of your script ( python - py)python will enter into its interactive interpreter mode (the promptwhen your script exitswhether it ends successfully or runs into an error at this pointyou can print the final values of variables to get more details about what happened in your code because they are in the top-level namespace you can also then import and run the pdb debugger for even more contextits postmortem mode will let you inspect the latest error if your script failed appendix also shows - in action how you run programs