I was surprised today to see that the following works without exception (at least in Python 2.7.3):
>>> try:
... pass
... except ThingThatDoesNotExist:
... print "bad"
...
>>>
I would think that this should raise the value NameErrorin the REPL, similar to the following:
>>> x = ThingThatDoesNotExist
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'ThingThatDoesNotExist' is not defined
Does anyone know what is going on here?
source
share