% cat oops.py def oops(): raise IndexError def doomed(): try: oops() except IndexError: print 'caught an index error!' else: print 'no error caught...' if __name__ == '__main__': doomed() % python oops.py caught an index error!