Python Debugging Handbook
by: HL Zimmerman
Print Length 页数: 206 pages
Publisher finelybook 出版社: Independently published (7 Feb. 2020)
Language 语言: English
ISBN-13: 9798610761725
ASIN: B084DJ6K9P
Book Description
By finelybook
Color Edition.This book is a systematic plan to debug your programs. The focus is not on the Python language,although Chapter 3 does cover the basics. Instead,my focus is always on debugging. If you’re new to Python debugging,I think this book is a good starting point. Experienced Python programmers might want to review the table of contents,to see if there’s anything special that catches their interest.The sample code demonstrates lists,tuples,loops,or classes,but in the simplest form I could imagine. Chapters 1-2 outline how to set up your Python debugging environment,and establish a debugging plan as you write your code.1.Work on small chunks of code,test,and then move on to the next piece.2.Keep multiple backup versions of your files.3.Have a clear idea of what you want your program to do.4.Use small data file samples that you know have clean data to develop your code. When you’ve tested your code and are confident there are no bugs,use live data connections or real data files. 5.Keep notes of where you stopped programming and the next steps.6.Divide and concur. Divide the code in half and test each half to see which half has the error. Repeat to drill down to the location with the error.7.When debugging,keep a record of experiments,so you know what you’ve already tried.Chapter 4 has simple suggestions for debugging your code,with specific examples of the code and results. Even if you’ve never seen Spyder or Python before,at the end of this chapter,I hope you’ll feel confident debugging most of the issues you’ll encounter.•With the Debugging Overview,you’ll learn about the Editor,Variable Explorer,and Debug Mode and Interactive Mode in the Console. We’ll look at those times when you don’t see your object in Variable Explorer,and explore why the Console traceback says “NameError.”•Delve into Debug Mode,including basic commands,how to set a breakpoint,and examples of stepping through the code.•Add Print Statements (and visual clues for the depth of loop statements).•Logging for those times when print statements roll off the screen.•Use Interactive Mode with several common Console commands and two magic commands. [object name]?dir(object)help(object)%debug%timeitChapter 5 briefly looks at the types of errors you may encounter,and then in Chapter 6,you can try out your debugging knowledge. We’ll look at the syntax for retrieving object values,type information,the length of objects or data structures,arguments,and return values. Because syntax varies based on the type and length of objects,there are numerous examples for strings,numbers,tuples,lists,and dictionaries. We’ll also look at the special “None” value,unique to Python.Chapter 7 is chock full of examples. The format for each example is the same: Description,Intended Outcome,Actual Result,Incorrect Code,Debugging Steps,How to Resolve the Issue,Good Code,and a Reference to earlier related topics.Finally,the Appendix-Reference chapter includes links to the Python.org docs and the iPython.readthedocs websites for more detailed information.
|1.Introduction
2.Debugging Overview
3.Python Basics
4.Debugging Tools
5.Exceptions
6.Try This
7.Examples
Appendix-URLS
ConclusionPython Debugging Handbook 9798608293733. zip[/erphpdown]