try-except-finally block in python 2.4
try-except-finally这种语法是在py2.5中才支持的,而在py2.4中只能单独使用try-except或try- finally。为了让脚本有更好的兼容性,只好绕过去了:
#/usr/bin/python2.6
try:
print 'try'
except:
print 'except'
finally:
print 'finally'
#/usr/bin/python2.4
try:
try:
print 'try'
except:
print 'except'
finally:
print 'finally'
从Chromium的代码库([Issue 140005](http://codereview.chromium.org/140005/diff/1/tool s/grit/grit/scons.py))中找到的方法,呵呵。