def err(): raise IndexErrordef aFunction(): try: err() except IndexError: print 'caught an index error!' else: print 'no error caught...'if __name__ == '__main__': aFunction()