error handling
Farshid Lashkari
no at spam.com
Thu Aug 10 19:59:56 EDT 2006
Chris wrote:
> But sometimes you can have too many of these statements in your
> program, and it starts to get tangled and nasty looking. Is there a way
> I can modify sys.error so that when the interpreter comes accross an
> IndexError it prints "That number is way too big!" before it exits?
Hi,
Try placing the try/except block around the main function of your program:
if __name__ == '__main__':
try:
main()
except IndexError:
sys.exit("That number is way too big!")
-Farshid
More information about the Python-list
mailing list