from typing import List def load_files(paths: List[str]): for path in paths: with open(path) as f: yield f.readlines() paths = [ "dict_gen.py", "enum.py", "for_loop.py", "gen.py", "lzy_load.py", ] for cont in load_files(paths): # code working with content print(cont)