remove item from list based on name
Peter Otten
__peter__ at web.de
Thu May 27 16:08:00 EDT 2004
Bart Nessux wrote:
> I am generating a list of file names... some of the files are locked by
> the OS (Windows XP) and I know the names of these files (NTUSER.DAT,
> ntuser.dat.LOG, etc.) But, I don't know their position in the list. Is
> there a way that I can delete these items from the list based on their
> names?
>>> from sets import Set
>>> list(Set(["a", "b", "c"]) - Set(["c", "d"]))
['a', 'b']
Remember to pass all filenames through os.path.normcase() before trying the
above.
Peter
More information about the Python-list
mailing list