Raise exception and catch it : Raise : Language Basics PYTHON examples


PYTHON examples » Language Basics » Raise »

 

Raise exception and catch it


Raise exception and catch it

def err():
    raise IndexError

def aFunction():
    try:
        err()
    except IndexError:
        print 'caught an index error!'
    else:
        print 'no error caught...'

if __name__ == '__main__': 
    aFunction()


           
       



    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
» Raise