[EMAIL PROTECTED] wrote: >newer python should use "for x in fh:", according to the doc : > >fh = open("your file") >for x in fh: print x > >which would only read one line at a time. > > > I have some other questions:
when "fh" will be closed? And what shoud I do if I want to explicitly close the file immediately after reading all data I want? >Ross Reyes wrote: > > >>HI - >>Sorry for maybe a too simple a question but I googled and also checked my >>reference O'Reilly Learning Python >>book and I did not find a satisfactory answer. >> >>When I use readlines, what happens if the number of lines is huge? I have >>a very big file (4GB) I want to >>read in, but I'm sure there must be some limitation to readlines and I'd >>like to know how it is handled by python. >>I am using it like this: >>slines = infile.readlines() # reads all lines into a list of strings called >>"slines" >> >>Thanks for anyone who knows the answer to this one. >> >> > > > -- http://mail.python.org/mailman/listinfo/python-list