. with open('filename') as file: ...process file... assert test, message raise Exc --- file = open('filename') try: ...process file... finally: file.close() --- xxx() yyy() --- try: xxx() except: pass yyy() ... ---- def func(): ... try: func() except: ....