About open file for Read
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Mon Dec 10 15:45:39 EST 2012
On Mon, 10 Dec 2012 08:36:22 -0800, moonhkt wrote:
> Hi All
>
> I am new in Python. When using open and then for line in f .
>
> Does it read all the data into f object ? or read line by line ?
Have you read the Fine Manual?
http://docs.python.org/2/library/stdtypes.html#file-objects
If you have read it, and the answer is still not clear, then please tell
us so we can improve the documentation.
`for line in open(file, "r"):` does not read the entire file into memory
at once, it iterates over the file reading one line at a time.
--
Steven
More information about the Python-list
mailing list