easier solution possible to find a stringpattern in a list?
csad7 at yahoo.com
Sat Jan 4 14:03:58 CET 2003
i was wondering if there is an easier solution to the following problem (i
am more or less a beginner in python):
i have a list of filenames and want to know if there is one or more files
with a given pattern in it.
a bit similar to what glob.glob(pattern) is doing.
my solution till now would be
files = [...]
pattern = "*.xsl"
number = len( [f for f in files if f.endswith(pattern)] )
if number > 0:
print number + " times in the list"
print "not in the list"
is there already a function in the standard modules that can do something
maybe even one which can handle more generalized patterns?
i guess i am looking for a version of glob which handles a list and not the
thanks for any help
More information about the Python-list