You can use stdlib functools.partial to bake in extra parameters. See
Also, in the future, please use code formatting so that the code is intelligible (either with the </> icon on the editing toolbar, or triple backtick ``` fences around the code blocks)