
April 19, 2015
11:28 a.m.
Steven D'Aprano <steve@pearwood.info> wrote:
This has two obvious, and slightly different, interpretations:
with open('spam.txt') as file: try: print(file.read()) except IOError: print('No spam here...') finally: print('done.')
try: with open('spam.txt') as file: print(file.read()) except IOError: print('No spam here...') finally: print('done.')
Sometimes I want the first, sometimes the second. And I expect a conscious mind-reading interpreter which gives me the one I want. If the interpreter in retrospect thinks it has given me the wrong one it should raise SorryError. Sturla