summaryrefslogtreecommitdiffhomepage
path: root/python.html.markdown
diff options
context:
space:
mode:
authorShashwat986 <chandra.shashwat@gmail.com>2014-08-02 19:37:28 +0530
committerShashwat986 <chandra.shashwat@gmail.com>2014-08-02 19:37:28 +0530
commite6a289be491c9b0f1a7c2d5b364de0c4c8241bd9 (patch)
treed51332b96f51bdd92b64f635642f5e0797b6a811 /python.html.markdown
parent10c07f30d50d9cda4b2ad193b212581c0b32152f (diff)
Update python.html.markdown
Added more details to try/except section.
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
####################################################