summaryrefslogtreecommitdiffhomepage
path: root/python.html.markdown
diff options
context:
space:
mode:
authorLevi Bostian <levi.bostian@gmail.com>2014-08-03 18:05:46 -0500
committerLevi Bostian <levi.bostian@gmail.com>2014-08-03 18:05:46 -0500
commita0af5e9a7b0a924cd70e8d3b76f0f9c7eaf0d4d3 (patch)
tree60299d6f707f1b55405cc6f4f6c374aca1f2df78 /python.html.markdown
parent10c07f30d50d9cda4b2ad193b212581c0b32152f (diff)
parentabc06a620bcb41d3e59c5f0c969d819294edc78e (diff)
Merge pull request #696 from Shashwat986/master
Updated python and python3 with try/except details
Diffstat (limited to 'python.html.markdown')
-rw-r--r--python.html.markdown4
1 files changed, 4 insertions, 0 deletions
diff --git a/python.html.markdown b/python.html.markdown
index aa077e57..5bec5190 100644
--- a/python.html.markdown
+++ b/python.html.markdown
@@ -334,6 +334,10 @@ try:
raise IndexError("This is an index error")
except IndexError as e:
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
####################################################