Hacker News new | ask | show | jobs
by chaosphere2112 4651 days ago
Yeah, but aren't we actually supposed to do this?

  for line in file:
1 comments

Yes, 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.
Most 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.