summaryrefslogtreecommitdiffhomepage
path: root/python3.html.markdown
diff options
context:
space:
mode:
authorEvgeniy Ginzburg <Nad.Oby@gmail.com>2014-08-05 17:41:41 +0300
committerEvgeniy Ginzburg <Nad.Oby@gmail.com>2014-08-05 17:41:41 +0300
commit611a00b5108e7a81eedbdba37a816df060ef3eca (patch)
treeccc09e48309f244534c9cdb64bd270fe5460be93 /python3.html.markdown
parent57036f128f5e874116729e67d8a77cd763f206d5 (diff)
parent4541a0f450cb3ee29b4c11c727b1dc17e3f436ca (diff)
Merge https://github.com/adambard/learnxinyminutes-docs
Diffstat (limited to 'python3.html.markdown')
-rw-r--r--python3.html.markdown9
1 files changed, 6 insertions, 3 deletions
diff --git a/python3.html.markdown b/python3.html.markdown
index de6d552a..6e901b6a 100644
--- a/python3.html.markdown
+++ b/python3.html.markdown
@@ -329,9 +329,12 @@ 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
-
-# Python's offers a fundamental abstraction called the Iterable.
+# Python offers a fundamental abstraction called the Iterable.
# An iterable is an object that can be treated as a sequence.
# The object returned the range function, is an iterable.
@@ -339,7 +342,7 @@ filled_dict = {"one": 1, "two": 2, "three": 3}
our_iterable = filled_dict.keys()
print(our_iterable) #=> range(1,10). This is an object that implements our Iterable interface
-i We can loop over it.
+# We can loop over it.
for i in our_iterable:
print(i) # Prints one, two, three