3 ms·
Yeah, but aren't we actually supposed to do this? for line in file:
by chaosphere2112 13y ago
Yeah, but aren't we actually supposed to do this?
for line in file:
- scott_s 13y agoYes, and that is the idiomatic way to read files in Python. I guess me and the author are looking at different Python programs, because slurping the whole file is not "by far the most common way" I have seen files read in the wild.
- rprospero 13y agoMost of my code slurps the entire file at a time. I can't actually think of any code we have that streams the code. Then again, most of my files are three dimensional matrices. There's nothing I can really do on a line by line basis.