Let's say I have the following:
src = itertools.chain(*map(lambda t: map(lambda u: ((t[0], ) + os.path.splitext(u)), t[2]), os.walk(src_folder)))
dst = itertools.chain(*map(lambda t: map(lambda u: ((t[0], ) + os.path.splitext(u)), t[2]), os.walk(dst_folder)))
This creates two lists of the format [(folder, base name, ext)]
for two directories.
I want to be able to find the files that are common in src
and dst
. I can do this with set(src) & set(dst)
as documented. But, what if I want to do it only by the folder and base name, and not by the extension? In other words, what if I want to do set intersection by a custom rule/function? How do I go about doing this?