Catch exceptions

Crutcher crutcher at gmail.com
Mon Feb 27 19:08:45 EST 2006


Without seeing more of your code, I'm not sure what you are doing
wrong. This works:
vvvvvvvv ex.py vvvvvvvvvvvvvv
def xopen(path):
  try:
    return open(path)
  except IOError, e:
    print 'Error:', e.args[1]

xopen('xyzzy')
^^^^^^^^^^^^^^^^^^^^^^^^^^
$ python ex.py
Error: No such file or directory

Could you give us the traceback?




More information about the Python-list mailing list