The Most Diabolical Python Antipattern
Marko Rauhamaa
marko at pacujo.net
Fri Jan 30 01:16:23 EST 2015
Ian Kelly <ian.g.kelly at gmail.com>:
> At least use "except Exception" instead of a bare except. Do you
> really want things like SystemExit and KeyboardInterrupt to get turned
> into 0?
How about:
==============================
try:
do_interesting_stuff()
except ValueError:
try:
log_it()
except:
pass
raise
==============================
Surprisingly this variant could raise an unexpected exception:
==============================
try:
do_interesting_stuff()
except ValueError:
try:
log_it()
finally:
raise
==============================
A Python bug?
Marko
More information about the Python-list
mailing list