[Tutor] capturing error msg in exception

Payal payal-python at scriptkitchen.com
Sun Jun 27 18:47:24 CEST 2010

Again a few queries regarding exceptions,

a. What is the difference between,

except ZeroDivisionError as e: print 'Msg : ' , e
except ZeroDivisionError ,e: print 'Msg : ' , e

Both show,
Msg :  integer division or modulo by zero

b. What is portable and correct way of writing,

except (NameError, ZeroDivisionError) as e: print 'Msg : ' , e

c. What is the correct Python of writing,
except  as e: print 'Msg : ' , e        # Capturing all exceptions

Thanks a lot for the help in advance.
With warm regards,

p.s. I am always confused where does one put the "?" when I am framing the
questions like I have done above (a, b and c)? 
This is completely OT query for native english speaking people :-)

More information about the Tutor mailing list