Remove items from a list

Stan Cook scook at elp.rr.com
Wed Sep 8 06:31:26 CEST 2004


Yes, I used the listdir.  The list is a list of files in the
directory.  I want to filter everything out but the ".dbf"
files.


"Dan Perl" <dperl at rogers.com> wrote in message
news:KOv%c.104$GRm.52 at news04.bloor.is.net.cable.rogers.com...
: 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
:
:


---
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