Hi to all I have a question about the for statement of python. I have the following piece of code where cachefilesSet is a set that contains the names of 1398 html files cached on my hard disk
for fn in cachefilesSet: fObj = codecs.open( baseDir + fn + '-header.html', 'r', 'iso-8859-1' ) u = fObj.read() v = u.lower() rows = v.split('\x0a') contentType = '' for r in rows: if r.find('content-type') != -1: y = r.find(':') if y != -1: z = r.find(';', y) if z != -1: contentType = r[y+1:z].strip() cE = r[z+1:].strip() characterEncoding = cE.strip('charset = ') else: contenType = r[y+1:].strip() characterEncoding = '' break if contentType == 'text/html': processHTMLfile( baseDir + fn + '-body.html', characterEncoding, cardinalita ) fileCnt += 1 if fileCnt % 100 == 0: print fileCnt this code stops at the 473th file instead of reaching 1398 however I changed the for and substituted it with a while in this way while cachefilesSet: fn = cachefilesSet.pop() ....... ....... the while loop reaches the 1398th file and is some 3-4 times faster than the for loop How is this possible? -- http://mail.python.org/mailman/listinfo/python-list