Re: [Tutor] capturing error msg in exception

2010-06-28 Thread Steven D'Aprano
On Mon, 28 Jun 2010 06:04:31 pm Adam Bark wrote: > I'm sure this "work it out yourself" answer is much more helpful. Unfortunately, the only correct answer is that there is no One True Answer. A bit like life, really. -- Steven D'Aprano ___ Tutor ma

Re: [Tutor] capturing error msg in exception

2010-06-28 Thread Adam Bark
On 28 June 2010 00:27, Steven D'Aprano wrote: > On Mon, 28 Jun 2010 03:12:39 am Adam Bark wrote: > > > I think the 'as' syntax is only available in Python 3.x > > You think wrong. It is available from Python 2.6 onwards. > I know, I corrected myself after Steve Willoughby pointed it out. > > >

Re: [Tutor] capturing error msg in exception

2010-06-27 Thread Steven D'Aprano
On Mon, 28 Jun 2010 03:12:39 am Adam Bark wrote: > I think the 'as' syntax is only available in Python 3.x You think wrong. It is available from Python 2.6 onwards. > Question marks go at the end of the sentence where you would normally > put a full stop if it wasn't a question. That's a terri

Re: [Tutor] capturing error msg in exception

2010-06-27 Thread Adam Bark
On 27 June 2010 18:22, Steve Willoughby wrote: > On 27-Jun-10 10:12, Adam Bark wrote: > >> On 27 June 2010 17:47, Payal > > > c. What is the correct Python of writing, >>except as e: print 'Msg : ' , e# Capturing all exceptions >> > > Since exceptions are (should be?) subclasses

Re: [Tutor] capturing error msg in exception

2010-06-27 Thread Steve Willoughby
On 27-Jun-10 10:12, Adam Bark wrote: On 27 June 2010 17:47, Payal c. What is the correct Python of writing, except as e: print 'Msg : ' , e# Capturing all exceptions Since exceptions are (should be?) subclasses of Exception, you can do: except Exception as e: I think the

Re: [Tutor] capturing error msg in exception

2010-06-27 Thread Adam Bark
On 27 June 2010 17:47, Payal 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. Wh

[Tutor] capturing error msg in exception

2010-06-27 Thread Payal
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 (NameEr