I encounter a problem while reading functional programming python.
def get_log_lines(log_file):
line = read_line(log_file)
while True:
try:
if complex_condition(line):
yield line
line = read_line(log_file)
except StopIteration:
raise
A try...except
statement is added to surround the read_line
. Why not just let read_line
throw the StopIteration
exception like this:
def get_log_lines(log_file):
line = read_line(log_file)
while True:
if complex_condition(line):
yield line
line = read_line(log_file)