Created
July 12, 2012 18:52
-
-
Save bbigras/3100108 to your computer and use it in GitHub Desktop.
demo lambda
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import os | |
path = "C:\\" | |
listeDeFichiers = os.listdir(path) | |
print "listeDeFichiers", listeDeFichiers | |
# Ne marche pas car listeDeFichiers ne contient que les noms de fichiers, pas les path | |
print "ne marche pas", filter(os.path.isfile, listeDeFichiers) | |
# marche | |
print "marche", filter(lambda nomFichier: os.path.isfile(os.path.join(path, nomFichier)), listeDeFichiers) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment