On 2006-11-17, Rares Vernica <[EMAIL PROTECTED]> wrote: > Sorry for not being clear from the beginning and for not using > clear variable names. > > Problem context: > > import os > dirs_exclude = set(('a', 'b', 'e')) > for root, dirs, files in os.walk('python/Lib/email'): > # Task: > # delete from "dirs" the directory names from "dirs_exclude" > # case-insensitive > > The solution so far is: > > for i in xrange(len(dirs), 0, -1): > if dirs[i-1].lower() in dirs_exclude: > del dirs[i-1] > > I am looking for a nicer solution.
I'd probably just skip over those dirs as I came them instead of troubling about mutating the list. Unless the list is needed in more than one place. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list