|
|
|
|
|
by harpiaharpyja
658 days ago
|
|
Well, there's also the fact that the entire thing could be replaced with... def cached_file_iterator(file_path):
with open(file_path, 'r') as f:
lines = [ line.strip() for line in f.readlines() ]
yield from iter(lines)
# Example usage:
if __name__ == "__main__":
file_path = 'example.txt' # Replace with your file path
iterator = cached_file_iterator(file_path)
for line in iterator:
print(line)
Which is functionally identical and FAR less code to maintain. |
|