Update python.html.markdown

Added more details to try/except section.
This commit is contained in:
Shashwat986 2014-08-02 19:37:28 +05:30
parent 10c07f30d5
commit e6a289be49

View File

@ -334,6 +334,10 @@ try:
raise IndexError("This is an index error") raise IndexError("This is an index error")
except IndexError as e: except IndexError as e:
pass # Pass is just a no-op. Usually you would do recovery here. pass # Pass is just a no-op. Usually you would do recovery here.
except (TypeError, NameError):
pass # Multiple exceptions can be handled together, if required.
else: # Optional clause to the try/except block. Must follow all except blocks
print "All good!" # Runs only if the code in try raises no exceptions
#################################################### ####################################################