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?
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 this :
try:
# stuff
except Exception, e:
return 'exception %s' % type(e)
© 2022 - 2024 — McMap. All rights reserved.
str()
, because you are already doing the interpolation using%s
,'exception %s' % type(e)
will work just fine – Marshallmarshallese