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

Slides:



Advertisements
Similar presentations
Exception Handling Genome 559. Review - classes 1) Class constructors - class myClass: def __init__(self, arg1, arg2): self.var1 = arg1 self.var2 = arg2.
Advertisements

UW CSE 190p Section 7/12, Summer 2012 Dun-Yu Hsiao.
Chapter 3: Editing and Debugging SAS Programs. Some useful tips of using Program Editor Add line number: In the Command Box, type num, enter. Save SAS.
Introduction to Computing Using Python Exceptions (Oops! When things go wrong)  Errors and Exceptions  Syntax errors  State (execution) errors.
Lecture 07 – Exceptions.  Understand the flow of control that occurs with exceptions  try, except, finally  Use exceptions to handle unexpected runtime.
Environments and Evaluation
Unittest in five minutes Ray Toal How to unit test Not manually, that's for sure You write code that exercises your code Perform assertions.
Introduction to Python Lecture 1. CS 484 – Artificial Intelligence2 Big Picture Language Features Python is interpreted Not compiled Object-oriented language.
Fruitful functions. Return values The built-in functions we have used, such as abs, pow, int, max, and range, have produced results. Calling each of these.
Python Mini-Course University of Oklahoma Department of Psychology Lesson 19 Handling Exceptions 6/09/09 Python Mini-Course: Lesson 19 1.
WEEK EXCEPTION HANDLING. Syntax Errors Syntax errors, also known as parsing errors, are perhaps the most common kind of complaint you get while.
November 15, 2005ICP: Chapter 7: Files and Exceptions 1 Introduction to Computer Programming Chapter 7: Files and Exceptions Michael Scherger Department.
General Programming Introduction to Computing Science and Programming I.
Exceptions 2 COMPSCI 105 S Principles of Computer Science.
Functions Reading/writing files Catching exceptions
More on Functions; Some File I/O UW CSE 190p Summer 2012.
Debugging and Interpreting Exceptions UW CSE 190p Summer 2012.
CSE1222: Lecture 6The Ohio State University1. Common Mistakes with Conditions (1)  Consider the following code: int age(26); if (age = 18) { cout
Exceptions COMPSCI 105 SS 2015 Principles of Computer Science.
UW CSE 190p Section 7/26, Summer 2012 Dun-Yu Hsiao.
Ruby Master Class Christina
CS 177 Week 10 Recitation Slides 1 1 Debugging. Announcements 2 2.
Introduction to Computing Using Python Exceptions (Oops! When things go wrong)  Errors and Exceptions  Syntax errors  State (execution) errors.
Lecture 4 Python Basics Part 3.
Python Built-in Exceptions Data Fusion Albert Esterline Source:
Lecture 07 – Exceptions.  Understand the flow of control that occurs with exceptions  try, except, finally  Use exceptions to handle unexpected runtime.
Python Exceptions and bug handling Peter Wad Sackett.
Debugging Ruth Anderson UW CSE 160 Winter
CSx 4091 – Python Programming Spring 2013 Lecture L2 – Introduction to Python Page 1 Help: To get help, type in the following in the interpreter: Welcome.
Interpreting Exceptions UW CSE 160 Spring 2015 download examples from the calendar 1.
Debugging M-Files Steve Gu Feb 08, Outline What’s Debugging? Types of Errors Finding Errors Debugging Example Using Debugging Features.
UW CSE 140 Section 1/10, Winter Find partners! Group can be 2-4 people. Try to share as much as possible about what you think with your teammates!
Python: Exception Handling Damian Gordon. Exception Handling When an error occurs in a program that causes the program to crash, we call that an “exception”
Chapter 13 Debugging Strategies Learning by debugging.
PYTHON PROGRAMMING Year 9. Objective and Outcome Teaching Objective Today we will look at conditional statements in order to understand how programs can.
COMPSCI 107 Computer Science Fundamentals
Chapter 2 Writing Simple Programs
Basic concepts of C++ Presented by Prof. Satyajit De
Introduction to Computing Science and Programming I
Fundamentals of Python: First Programs
George Mason University
Lecture 4 Python Basics Part 3.
Functions.
Scripts & Functions Scripts and functions are contained in .m-files
Chapter 14: Exception Handling
Some Basics for Problem Analysis and Solutions
Conditionals (if-then-else)
Ruth Anderson UW CSE 160 Winter 2017
CSE341: Programming Languages Section 1
Ruth Anderson CSE 140 University of Washington
Python’s Errors and Exceptions
Ruth Anderson UW CSE 160 Spring 2018
Lecture 4 Python Basics Part 3.
Escape sequences: Practice using the escape sequences on the code below to see what happens. Try this next code to help you understand the last two sequences.
Introduction to Computer Programming
ERRORS AND EXCEPTIONS Errors:
(Oops! When things go wrong)
Michael Ernst CSE 140 University of Washington
Introduction to Python: Day Three
Lesson 10: Dictionaries Class Chat: Attendance: Participation
Advanced Python Concepts: Exceptions
Python Syntax Errors and Exceptions
Advanced Python Concepts: Exceptions
Introduction to Python
Exception Handling COSC 1323.
Python Exceptions and bug handling
Debugging UW CSE 160.
UW CSE 190p Section 6/28, Summer 2012 Dun-Yu Hsiao.
Debugging 101 Exterminating Vermin.
Presentation transcript:

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

Homework/Quiz Questions?

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.

Outlines PDB recap Error messages Debugging exercise

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

Common Error Types AssertionError EOFError IndexError 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.

KeyError KeyboardInterrupt NameError 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.

SyntaxError IndentationError TypeError 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.

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

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

Type Error? Print, type PDB Change indentation

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

Another Type Error friends = friends(rj, "Mercutio")

Questions?