Files
codeql/python/ql/src/Exceptions/UnguardedNextInGeneratorGood.py
2018-11-19 15:10:42 +00:00

12 lines
328 B
Python

def separate_headers(files):
for file in files:
lines = iter(file)
try:
header = next(lines) # Will raise StopIteration if lines is exhausted
except StopIteration:
#Empty file -- Just ignore
continue
body = [ l for l in lines ]
yield header, body