From the os.path.join()
documentation:
Join one or more path components intelligently. If any component is an absolute path, all previous components (on Windows, including the previous drive letter, if there was one) are thrown away, and joining continues.
A /
at the start makes /tmp
an absolute path.
If you wanted to join multiple path elements that perhaps contain a leading path separator, then strip those first:
os.path.join(*(elem.lstrip(os.sep) for elem in elements))
Special-casing absolute paths makes it possible for you to specify either a relative path (from a default parent directory) or an absolute path and not have to detect if you have an absolute or relative path when constructing your final value.