On Apr 13, 2007, at 4:47 AM, 7stud wrote: > On Apr 13, 3:36 am, "7stud" <[EMAIL PROTECTED]> wrote: >> >>> It is if the file is smaller than the buffer size. >> >> How is that relevant? >> > > If I put 100 lines of text in a file with each line having 50 > characters, and I run this code: > > import sys > > lst = [] > for line in open("aaa.txt"): > print "an iteration" > lst.append(line) > break > > print lst > > > The output is: > > $ python test1.py > > an iteration > ['helleo haljdfladj ahdflasdjf ds hdljfalsdjfdsljfds \n'] > > It seems clear to me that the whole file wasn't first read into a > buffer before the code started processing the data.
The break statement causes it to bail after the first iteration, so that doesn't really prove your point. For example: lst = [] for line in ['we', 'all live', 'in a yellow', 'submarine']: print "an iteration" lst.append(line) break print lst The output is: an iteration ['we'] -- http://mail.python.org/mailman/listinfo/python-list