1 / 14

Debugging Strategies and Common Error Types in Python Programming

This resource provides a comprehensive overview of debugging techniques using Python's PDB module. It outlines essential commands like `import pdb`, `pdb.set_trace()`, and discusses common Python error types including AssertionError, EOFError, IndexError, and more. Students are encouraged to save their work and report any material-related questions to the TA. A focus on understanding these errors aids in the development of robust coding practices and enhances problem-solving skills when debugging.

lynde
Download Presentation

Debugging Strategies and Common Error Types in Python Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. UW CSE 190p Section 7/19, Summer 2012 Dun-Yu Hsiao

  2. Homework/Quiz Questions?

  3. Before We Start • Create and remember save every code and steps you try today! • If you have any question about today’s material, email your report to TA.

  4. Outlines • PDB recap • Error messages • Debugging exercise

  5. PDB Recap • Using PDB • import pdb • pdb.set_trace() • Next, continue, quit, print, list, step in, return • Careful about overwriting variables

  6. Common Error Types • AssertionError • Raised when an assert statement fails. • EOFError • Raised when one of the built-in functions (input() or raw_input()) hits an end-of-file condition (EOF) without reading any data. • IndexError • Raised when a sequence subscript is out of range.

  7. KeyError • Raised when a mapping (dictionary) key is not found in the set of existing keys. • KeyboardInterrupt • Raised when the user hits the interrupt key (normally Control-C or Delete). • NameError • Raised when a local or global name is not found.

  8. SyntaxError • Raised when the parser encounters a syntax error. • IndentationError • Base class for syntax errors related to incorrect indentation. • TypeError • Raised when an operation or function is applied to an object of inappropriate type.

  9. Unbound Local Error • Go back and check variable names friends = friends(graph, fren) fof= fof | friends  friend = friends(graph, fren) fof= fof | friend

  10. Assertion Error? • Check output • Print • PDB • How to correctly make the user as a set? user=set(user)  user=set([user])

  11. Type Error? • Print, type • PDB • Change indentation

  12. More Errors • fof = fof.remove(user) • Keep user as a set • Keep the remove method

  13. Another Type Error • friends = friends(rj, "Mercutio")

  14. Questions?

More Related