,

Python – yield a text file


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 :)

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *