1 2 3 4 5 6 7 8
def foo(): file = None try: file = open('test.json') except Exception: pass file.name # error