Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you assign an exception to a local variable in Python 2.5?

In Python 2.6+, you can handle exceptions like this:

  try:
    # stuff
  except Exception as e:
    return 'exception %s' % type(e)

What is the equivalent in 2.5?

like image 606
Josh Glover Avatar asked May 25 '11 14:05

Josh Glover


1 Answers

Like this :

try:
    # stuff
except Exception, e:
  return 'exception %s' % type(e)
like image 167
Cédric Julien Avatar answered Oct 14 '22 13:10

Cédric Julien