kuroko/test/testFinally.krk

74 lines
1.1 KiB
Python
Raw Permalink Normal View History

2021-03-18 13:52:30 +03:00
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))