[Tutor] capturing error msg in exception

Adam Bark adam.jtm30 at gmail.com
Sun Jun 27 19:12:39 CEST 2010


On 27 June 2010 17:47, Payal <payal-python at scriptkitchen.com> wrote:

> Hi,
> 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,
> -Payal
> --
>
> 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 :-)
>
>
I think the 'as' syntax is only available in Python 3.x


Question marks go at the end of the sentence where you would normally put a
full stop if it wasn't a question.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100627/d8f8cf8d/attachment.html>


More information about the Tutor mailing list