when i execute my program without an argument i receive,


infile = sys.argv[1]

IndexError: list index out of range
is there a way that i could suppress this and add my own error code



Hi Bryan,

You are probably better off pursuing Danny's suggestion. But, this is what you asked for:

IDLE 1.1.4
class CustomError(Exception):
        pass

import sys
try:
        infile = sys.argv[1]
except IndexError:
        raise CustomError, "Some msg (this is optional)"


Traceback (most recent call last):
  File "<pyshell#12>", line 4, in -toplevel-
    raise CustomError, "Some msg (this is optional)"
CustomError: Some msg (this is optional)


Best,

Brian vdB
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to