Python public recipes
The os.path.relpath() function returns the relative path to a file or directory. In this case, it returns the path to the /etc/passwd file.
Shortcut: file.path.relative
import os
os.path.relpath(directory, base_directory)