Remove items from a list

Leif K-Brooks eurleif at ecritters.biz
Wed Sep 8 07:15:56 CEST 2004


Stan Cook wrote:
> I was trying to take a list of files in a directory and remove all but the ".dbf" files.

Assuming the variable "files" is the list of files:

files = [fname for fname in files if fname.endswith('.dbf')]



More information about the Python-list mailing list