Wednesday, November 12, 2014

except block types evaluated lazily

>>> try:
...    raise Exception()
... except Exception:
...    print "OK"
... except doesntexist:
...    pass
...
OK
>>>
>>> try:
...    raise Exception()
... except doesntexist:
...    pass
... except Exception:
...    print "OK"
...
Traceback (most recent call last):
  File "<stdin>", line 3, in <module>
NameError: name 'doesntexist' is not defined

No comments:

Post a Comment