However, most Python programmers tend to just read the
entire file into one huge string and process it that way.
I feel funny doing that. Having used machines with very
limited amounts of RAM, I tend to try to keep my file
processing to a single line at a time. However, that
method is going the way of the dodo.
contents = file('filename.txt').read()
all_input = sys.stdin.read()
This is not the correct way to do things. The first example given is better. for line in file('filename.txt'):
print line
Generators are a beautiful thing [1][2][1] http://stackoverflow.com/questions/519633/lazy-method-for-re...