mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-11-26 09:21:00 +03:00
Update python.html.markdown
Added more details to try/except section.
This commit is contained in:
parent
10c07f30d5
commit
e6a289be49
@ -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
|
||||
|
||||
|
||||
####################################################
|
||||
|
Loading…
Reference in New Issue
Block a user