Advertisement
Guest User

Untitled

a guest
Jun 14th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.99 KB | None | 0 0
  1. >>> def doStuff():
  2. ...     try:
  3. ...         print "I'm doing stuff"
  4. ...         a = [0]
  5. ...         print a[1]
  6. ...     except:
  7. ...         print "Something has gone wrong"
  8. ...
  9. >>> doStuff()
  10. I'm doing stuff
  11. Something has gone wrong
  12.  
  13.  
  14.  
  15.  
  16.  
  17. >>> def doStuff():
  18. ...     print "I'm doing stuff"
  19. ...     a = [0]
  20. ...     print a[1]
  21. ...
  22. >>> doStuff()
  23. I'm doing stuff
  24. Traceback (most recent call last):
  25.  File "<stdin>", line 1, in <module>
  26.  File "<stdin>", line 4, in doStuff
  27. IndexError: list index out of range
  28.  
  29.  
  30.  
  31.  
  32.  
  33. >>> def doStuff():
  34. ...     try:
  35. ...         print "I'm doing stuff"
  36. ...         raise Exception
  37. ...     except:
  38. ...         print "Something has gone wrong"
  39. ...
  40. >>> doStuff()
  41. I'm doing stuff
  42. Something has gone wrong
  43.  
  44.  
  45.  
  46.  
  47.  
  48. >>> def doStuff():
  49. ...     print "I'm doing stuff"
  50. ...     raise Exception
  51. ...
  52. >>> doStuff()
  53. I'm doing stuff
  54. Traceback (most recent call last):
  55.  File "<stdin>", line 1, in <module>
  56.  File "<stdin>", line 3, in doStuff
  57. Exception
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement