buggy python interpretter or am I missing something here?
me
noone at all.net
Mon Jan 27 01:17:41 EST 2014
On Sun, 26 Jan 2014 21:04:57 -0800, Gary Herron wrote:
>
> Never *ever* have a bare except like that. If it gets invoked, you have
> no idea why. A simple typo like ixd instead of idx or a(idx) instead
> of a[idx] would raise an exception but give you no idea why.
>
> Do
> try:
> ...
> except Exception,e:
> print e
> at the absolute minimum.
> (Python 3 syntax would differ slightly, but the advice is the same.)
>
> Perhaps printing a traceback along with the exception would help. Add
> traceback.print_exc()
So here's the clencher without debating the merits bare except: since a
bare catch(...) is totally acceptable in the c++ world.
When I have except: by itself the program fails...but simply adding the
"except Exception,e: " causes the program to work correctly.
To me that signifies an undefined behavior of the python specification,
or at least bad behavior of the python interpreter I'm using. If you can
syntactically use a bare except: without generating an invalid syntax
error then it should have a well defined and predictable outcome.
If in fact the "except Exception, e:" is what's required then a bare
except shouldn't be considered valid syntax at all, right?
kind regards
More information about the Python-list
mailing list