Python 3 - raise statement

Viewed 15686

I am currently working through Learning Python by Mark Lutz and David Ascher and I have come across a section of code that keeps bringing up errors. I am aware that that book was written with Python 2 in mind unlike the Pyhton 3 I am using. I was wondering if anyone knew a solution to my problem as I have looked everywhere but I have been unable to find a solution .

.........................

MyBad = 'oops'

def stuff( ):
    raise MyBad

try:
    stuff( )
except MyBad:
    print('got it')
2 Answers
Related