
Oct. 10, 2023
2:27 p.m.
Dom Grigonis writes:
Why would this not be a good option? 1 extra line compared to walrus, but no DRY issue. with open(“fn") as f: while True: line = f.readline() if line and check(line): process(line) else: break
Works for me. I suspect you can construct situations where it would be a lot uglier. But I'm not a fan of the walrus in the first place, so I'm not going to take this any further. Steve