Milton,
This isn't terribly elegant, but it gets the job done:
dirs = ['C:\Images', 'C:\Images\2006', 'C:\Images\2007', 'C:\Music',
'C:\Files', 'C:\Software', 'C:\Software\Python', 'C:\Software\iTunes']
exclude_list =
['Software','Images']
def foo(d):
retval = d
for item in exclude_list:
if item in d:
retval = False
return retval
dirs = map(foo, dirs)
dirs = filter(bool, dirs) # removes the Falses
print dirs
Milton Segura wrote:
Hello, I'm trying to exclude files from a list using the following code:
for item in dirs:
if item.find('Software') > -1:
dirs.remove(item)
elif item.find('Images') > -1:
dirs.remove(item)
let's supose dirs = ['C:\Images', 'C:\Images\2006', 'C:\Images\2007',
'C:\Music', 'C:\Files', 'C:\Software', 'C:\Software\Python',
'C:\Software\iTunes']
For some reason.. it just won't exclude them.
I'd like to know why and how to fix it.
Thanks in advance.
Milton
------------------------------------------------------------------------
Explore the seven wonders of the world Learn more!
<http://search.msn.com/results.aspx?q=7+wonders+world&mkt=en-US&form=QBRE>
--
Shane Geiger
IT Director
National Council on Economic Education
[EMAIL PROTECTED] | 402-438-8958 | http://www.ncee.net
Leading the Campaign for Economic and Financial Literacy
begin:vcard
fn:Shane Geiger
n:Geiger;Shane
org:National Council on Economic Education (NCEE)
adr:Suite 215;;201 N. 8th Street;Lincoln;NE;68508;United States
email;internet:[EMAIL PROTECTED]
title:IT Director
tel;work:402-438-8958
x-mozilla-html:FALSE
url:http://www.ncee.net
version:2.1
end:vcard
--
http://mail.python.org/mailman/listinfo/python-list