Combine two paths with common folder

Viewed 3361

Is there a way in python to combine two paths with os.path or any other library which doesn't repeat common subfolders? i.e.

root = '/home/user/test'

rel_path = 'test/files/file.txt'

os.combine(root, rel_path)

And returning /home/user/test/files/file.txt instead /home/user/test/test/files/file.txt

3 Answers
Related