12.07.2015 Views

Think Python - Denison University

Think Python - Denison University

Think Python - Denison University

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

202 Appendix A. DebuggingA.3.5 No,Ireally needhelp.It happens. Even the best programmers occasionally get stuck. Sometimes you work on a programsolong that you can’t seetheerror. A freshpair of eyes isjustthe thing.Before you bring someone else in, make sure you are prepared. Your program should be as simpleas possible, and you should be working on the smallest input that causes the error. You should haveprintstatementsintheappropriateplaces(andtheoutputtheyproduceshouldbecomprehensible).You should understand the problem well enough todescribe it concisely.When you bring someone intohelp, be suretogive them the informationthey need:• Ifthere isan errormessage, what isitand what part of theprogram does itindicate?• What was the last thing you did before this error occurred? What were the last lines of codethat you wrote, or what isthe new testcase that fails?• What have you triedsofar,and what have you learned?Whenyoufindthebug,takeasecondtothinkaboutwhatyoucouldhavedonetofinditfaster. Nexttimeyou seesomething similar,you willbe able tofind thebug morequickly.Remember, the goal is not just to make the program work. The goal is to learn how to make theprogram work.

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

Saved successfully!

Ooh no, something went wrong!