human
Python: Get relative path from comparing two absolute paths
assistant
Here is some code to get the common prefix from comparing two absolute paths '/usr/var' and '/usr/var2/log'

os.path.commonprefix(['/usr/var', '/usr/var2/log'])

#Warning: this code generation is experimental. Please inspect the code for any bugs before executing.