[Python-ideas] Extending error handling on with statements.
greg.ewing at canterbury.ac.nz
Mon Mar 28 07:11:30 CEST 2011
Jakob Bowyer wrote:
> with open('nofile.txt','r') as inp:
> #nofile.txt does not exist and throws an exception
> except IOError:
> with open('another.txt','r') as inp:
> #carry on where you left off...
You could write this as
inp = open('nofile.txt','r')
inp = open('another.txt','r')
More information about the Python-ideas