Hello,
like this question I want to pass a function with arguments. But I want to pass it to built-in functions.
Example:
files = [ 'hey.txt', 'hello.txt', 'goodbye.jpg', 'howdy.gif' ]
def filterex(path, ex):
pat = r'.+\.(' + ex + ')$'
match = re.search(pat, path)
return match and match.group(1) == ex)
I could use that code with a for loop and an if statement but it's shorter and maybe more readable to use filter(func, seq). But if I understand correctly the function you use with filter only takes one argument which is the item from the sequence.
So I was wondering if it's possible to pass more arguments?