kuroko/test/testFinally.krk
2021-03-18 19:52:30 +09:00

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))