def yield_file(filepath): with open(filepath, 'r') as f for line in f: yield line
Usage:
for line in yield_file(filepath): do_something(line) # whatever you want :)
def yield_file(filepath): with open(filepath, 'r') as f for line in f: yield line
Usage:
for line in yield_file(filepath): do_something(line) # whatever you want :)
Leave a Reply