Mutating the list you're iterating over is an undefined corner of the Python language, so let's avoid it: http://docs.python.org/2/tutorial/controlflow.html#for-statements. Actually, the longstanding use of remove() here wouldn't pass review for me; it does a linear scan through the whole list, strcmping all the way. Eww. Let's make an unignored_folders() generator which yields the good folders and avoid this whole mudpit. :-)