exception question

Oleg Broytmann phd at phd.pp.ru
Tue Apr 9 05:10:50 EDT 2002


On Tue, Apr 09, 2002 at 10:56:03AM +0200, Henning Peters wrote:
> i am asking me, if it is possible to catch an exception and to save the
> exception value in a variable?!
> 
> try:
> ...
> except: __all_exceptions__, error:
> ...

   Two ways to do it:

1:
try:
   ...
except:
   e1, e2, e3 = sys.exc_info()

2:
try:
   ...
except Exception, e:
   ...

Oleg.
-- 
     Oleg Broytmann            http://phd.pp.ru/            phd at phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.





More information about the Python-list mailing list