Raise exception and catch it : Raise « Language Basics « Python
- Python
- Language Basics
- Raise
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 examples in the same category