Toggle navigation
Home
Latest pastes
FAQ
Random
BitBin is shutting down!
Register
Login
Simple python code to Earn
SUBMITTED BY:
Guest
DATE:
Dec. 15, 2013, 6:03 a.m.
FORMAT:
Python
SIZE:
662 Bytes
Raw
Download
Tweet
HITS:
725
Go to comments
Report
# exception
# nested try block
# scope of try block: dynamic
# exception propagates towards the try block
#
def
g
()
:
print
(
"five"
)
print
(
10
/
0
)
print
(
"six"
)
def
f
()
:
print
(
"four"
)
g
()
print
(
"seven"
)
try
:
print
(
"one"
)
f
()
print
(
"ten"
)
print
(
"end of try"
)
except
NameError
as
e
:
print
(
"no such name"
)
print
(
e
)
except
Exception
as
e
:
print
(
e
,
type
(
e
))
# can get the stack trace
except
:
# catch all handler; should be the last
print
(
"something wrong"
)
finally
:
# always executed
print
(
"this is final"
)
print
(
"end of program"
)
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus