Lisp's "some" in Python? -
i have list of strings , list of filters (which strings, interpreted regular expressions). want list of elements in string list accepted @ least 1 of filters. ideally, i'd write
[s s in strings if (lambda f: re.match (f, s), filters)] where defined as
def (pred, list): x in list: res = pred (x) if res: return res return false is available in python, or there more idiomatic way this?
there function called any want want. think looking this:
[s s in strings if any(re.match(f, s) f in filters)]
Comments
Post a Comment