[Tutor] capturing error msg in exception
Steve Willoughby
steve at alchemy.com
Sun Jun 27 19:22:23 CEST 2010
On 27-Jun-10 10:12, Adam Bark wrote:
> On 27 June 2010 17:47, Payal <payal-python at scriptkitchen.com
> 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 'as' syntax is only available in Python 3.x
It's in Python 2 as well. At least I see it in 2.6.4, probably earlier
too (but I'm not sure ATM how early it showed up).
More information about the Tutor
mailing list