# Default Exception Handler
a
--------------------------------------------------------------------------- NameError Traceback (most recent call last) <ipython-input-2-06bae13eb8cf> in <module>() 1 # Default Exception Handler ----> 2 a NameError: name 'a' is not defined
try:
a
except NameError:
print("a is not defined")
finally:
print("Runs no matter exception occur or not")
a is not defined Runs no matter exception occur or not
assert 1 == 1
assert 1 == 2
--------------------------------------------------------------------------- AssertionError Traceback (most recent call last) <ipython-input-5-a810b3a4aded> in <module>() ----> 1 assert 1 == 2 AssertionError:
with open("../README.md") as f:
pass
The above code perform both open() and close()