On 04/16/2015 12:22 AM, Andrew Barnert wrote:
Why does the finally come before the except? Also, it's still indented with the with, which means you seem to be defining with-except-finally in terms of with-finally, and not defining with-finally at all. Did you mean to have the finally after the except and dedented?
Oops, my bad. I did mean to put the finally-block after the except-block:
try: with open('spam.txt') as file: print(file.read()) except IOError: print('No spam here...') finally: print('done.')