6 ms·
The following will work across 3 and 2 versions going back pretty far. It's necessary if you want to support pre-2.5 versions (where `as` was introduced):
by briancurtin 16y ago
The following will work across 3 and 2 versions going back pretty far. It's necessary if you want to support pre-2.5 versions (where `as` was introduced):
import sys
try:
fn()
except (IOError, TypeError):
err = sys.exc_info()[1]
print(err)
http://docs.pythonsprints.com/python3_porting/py-porting.html#exceptions http://docs.pythonsprints.com/python3_porting/py-porting.htm...
- koenigdavidmj 16y agoStill kind of ugly, and not something which you want to litter than Django sources. Especially if you are going to put them all back when 2.4 support is dropped.