try with else statement : Try Else : Language Basics PYTHON examples


PYTHON examples » Language Basics » Try Else »

 

try with else statement


try with else statement


MyError = 'hello'

def oops():
    raise MyError, 'My error'

def doomed():
    try:
        oops()
    except IndexError:
        print 'caught an index error!'
    except MyError, data:
        print 'caught error:', MyError, data
    else:
        print 'no error caught...'

if __name__ == '__main__':
    doomed()

           
       



    Related Scripts with Example Source Code in same category :

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON examples

 Navioo Language Basics
» Try Else