regex = re.compile('f\\(\\s*([^,]+)\\s*,\\s*([^,]+)\\s*\\)')
with open('my_file.txt') as f:
    for line in f:
        result = regex.search(line)
Python - How to use regexp on file, line by line, in Python