About open file for Read

2012-12-10 Thread moonhkt
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 ? f=open(file, 'r') for line in f: if userstring in line: print file: + os.path.join(root,file) break

Re: About open file for Read

2012-12-10 Thread Dave Angel
On 12/10/2012 11:36 AM, 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 ? f=open(file, 'r') for line in f: if userstring in line: print file: +

Re: About open file for Read

2012-12-10 Thread Peter Otten
Dave Angel wrote: On 12/10/2012 11:36 AM, 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 ? f=open(file, 'r') for line in f: if userstring in line:

Re: About open file for Read

2012-12-10 Thread Steven D'Aprano
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