Have a list of paths + filenames, all starting with the same root_dir
. How do I use partial?
Attempt
from os.path import join as path_join
from functools import partial
from tempfile import gettempdir
root_dir = gettempdir()
root_join = partial(path_join, path=root_dir)
root_join('foo')
However this throws an error:
TypeError: join() got multiple values for keyword argument 'path'
Obviously I can write a new function:
root_join = lambda root=root_dir, *a: path_join(root_dir, *a)
However I would like to solve this using partial
. Any clue how?