Replace function in function with functools.partial call