What's the use of the else in try/except/else?
greg
greg at cosc.canterbury.ac.nz
Wed May 13 00:20:25 EDT 2009
kj wrote:
> Wow. As rationales for syntax constructs go, this has got to be
> the most subtle one I've ever seen...
It's to avoid masking bugs. Suppose you accidentally
wrote
try:
v = mumble.field
sys.warming('field was actually there?')
except AttributeError:
pass
Then you could easily fail to notice that
you had written 'warming' instead of 'warning'.
--
Greg
More information about the Python-list
mailing list