74 lines
1.1 KiB
Python
74 lines
1.1 KiB
Python
def f():
|
|
try:
|
|
print("in try")
|
|
return 'try'
|
|
print("???")
|
|
except:
|
|
print("exception?")
|
|
finally:
|
|
print("in finally")
|
|
return 'finally'
|
|
|
|
print(f())
|
|
|
|
def f():
|
|
try:
|
|
print("in try")
|
|
raise Exception()
|
|
except:
|
|
print("exception?")
|
|
return "exception"
|
|
finally:
|
|
print("in finally")
|
|
return 'finally'
|
|
|
|
print(f())
|
|
|
|
def f():
|
|
try:
|
|
print("in try")
|
|
raise Exception()
|
|
except:
|
|
print("exception?")
|
|
return "exception"
|
|
finally:
|
|
print("in finally")
|
|
|
|
print(f())
|
|
|
|
def f():
|
|
try:
|
|
print("in try")
|
|
raise Exception()
|
|
finally:
|
|
print("in finally")
|
|
return 42
|
|
|
|
print(f())
|
|
|
|
def f():
|
|
try:
|
|
print("in try")
|
|
raise Exception()
|
|
finally:
|
|
print("in finally")
|
|
|
|
try:
|
|
print(f())
|
|
except:
|
|
print("Raised exception.")
|
|
|
|
def f():
|
|
try:
|
|
print("in try")
|
|
raise Exception()
|
|
except:
|
|
raise ValueError()
|
|
finally:
|
|
print("in finally")
|
|
|
|
try:
|
|
print(f())
|
|
except Exception as e:
|
|
print("Raised",type(e))
|