Remove items from a list

Dan Perl dperl at rogers.com
Wed Sep 8 00:23:06 EDT 2004


What is the content of _dbases?  How do you create that list?  If I
understand correctly, it is a list of file names that you may have gotten
with os.listdir( ).

And I want to make sure I understand the problem.  Are you trying to remove
the names from the list or are you trying to remove the files themselves?
Just making sure that it's not the latter...

Can you put more in your example, something that I may be able to run and
see the results?

Dan

"Stan Cook" <scook at elp.rr.com> wrote in message
news:ysv%c.32876$Dl4.14767 at fe2.texas.rr.com...
I was trying to take a list of files in a directory and remove all but the
".dbf" files.  I used the following to try to remove the items, but they
would not remove.  Any help would be greatly appreciated.

x = 0
for each in _dbases:
    if each[-4:] <> ".dbf":
            del each            # also tried:   del _dbases[x]
    x = x + 1

I must be doing something wrong, but it acts as though it is....

signed
. . . . . at the end of my rope....!


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.749 / Virus Database: 501 - Release Date: 9/1/04





More information about the Python-list mailing list