examples/exceptions/finally.py
from __future__ import print_function

def read_file(f):
    print("before " + f)
    try:
        with open(f, 'r') as fh:
            number = int(fh.readline())
            print(30 / number)
    except Exception:
        print("  there was a problem in " + f)
    finally:
        print("In finally after " + f)
    print("after  " + f)

# 3 of the 4 file exist
files = 'one.txt', 'zero.txt', 'two.txt', 'three.txt'

for f in files:
    read_file(f)

# before one.txt
# 30
# In finally after one.txt
# after  one.txt
# before zero.txt
#   there was a problem in zero.txt
# In finally after zero.txt
# after  zero.txt
# before two.txt
#   there was a problem in two.txt
# In finally after two.txt
# after  two.txt
# before three.txt
# 10
# In finally after three.txt
# after  three.txt