sosey / astronomy-resources

Information, Tutorials and Help for Astronomers writing code for data analysis and vizualization
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

With statement #2

Open dborncamp opened 9 years ago

dborncamp commented 9 years ago

One thing I do not have a good handle on is the use of the with statement which I commonly see used to read in files. The python documentation (https://docs.python.org/2/reference/compound_stmts.html#the-with-statement) describes it as a compound statement that can be used to replace try catch statements.

I don't understand what will happen if there is an issue. If, or when, in the case of reading in a file (will get an EOF exception), there is an exception what happens? And how do I specify what happens for different exceptions, or do I have that ability?