If you want to process the file line by line, you can simply use the file object as an iterator:
for line in open('file', 'r'): print line
This is a fairly efficient memory; if you want to work with a batch of lines at a time, you can also use the readlines() method of the file object with the sizehint parameter. This is read in sizehint bytes plus enough bytes to complete the last line.
spinlok
source share