On May 7, 8:46 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > 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 > [snip] I'd like to point out what look like 2 errors in the code:
1. You have "contenType" instead of "contentType" in "contenType = r[y +1:].strip()". 2. The string method "strip(...)" treats its string argument as a _set_ of characters to strip, so "cE.strip('charset = ')" will strip any leading and trailing "c", "h", "a", etc., which isn't what I think you intended. -- http://mail.python.org/mailman/listinfo/python-list