continue vs. pass in this IO reading and writing
ahlusar.ahluwalia at gmail.com
Thu Sep 3 17:05:31 CEST 2015
I am experimenting with many exception handling and utilizing continue vs pass. After pouring over a lot of material on SO and other forums I am still unclear as to the difference when setting variables and applying functions within multiple "for" loops.
Specifically, I understand that the general format in the case of pass and using else is the following:
However, I am uncertain as to how this executes in a context like this:
from collections import OrderedDict
interesting_files = glob.glob("*.csv")
header_saved = False
with open('merged_output_mod.csv','w') as fout:
for filename in interesting_files:
print("execution here again")
with open(filename) as fin:
header = next(fin)
print("Entering Try and Except")
if not header_saved:
header_saved = True
print("We got here")
for line in fin:
My questions are (for some reason my interpreter does not print out any readout):
1. after the exception is raised does the continue return back up to the beginning of the for loop (and the "else" conditional is not even encountered)?
2. How would a pass behave in this situation?
Thanks for your feedback.
More information about the Python-list