How can I handle multiple exceptions?
05:27 10 Aug 2016

I'm a Python learner, trying to handle a few scenarios:

  1. Reading a file.

  2. Formatting Data.

  3. Manipulating/Copying Data.

  4. Writing a file.

So far, I have:

try:
   # Do all
except Exception as err1:
   print err1
   # File Reading error/ File Not Present

except Exception as err2:
   print err2
   # Data Format is incorrect
except Exception as err3:
   print err3
   # Copying Issue
except Exception as err4:
   print err4
   # Permission denied for writing

The idea of implementing in this fashion is to catch the exact error for all different scenarios. I can do it in all separate try/except blocks.

Is this possible? And would it be reasonable?

python python-2.7