MCPcopy Index your code
hub / github.com/python/cpython / join

Function join

Lib/posixpath.py:73–93  ·  view source on GitHub ↗

Join two or more pathname components, inserting '/' as needed. If any component is an absolute path, all previous path components will be discarded. An empty last part will result in a path that ends with a separator.

(a, /, *p)

Source from the content-addressed store, hash-verified

71# Insert a '/' unless the first part is empty or already ends in '/'.
72
73def join(a, /, *p):
74 """Join two or more pathname components, inserting '/' as needed.
75 If any component is an absolute path, all previous path components
76 will be discarded. An empty last part will result in a path that
77 ends with a separator."""
78 a = os.fspath(a)
79 sep = _get_sep(a)
80 path = a
81 try:
82 for b in p:
83 b = os.fspath(b)
84 if b.startswith(sep) or not path:
85 path = b
86 elif path.endswith(sep):
87 path += b
88 else:
89 path += sep + b
90 except (TypeError, AttributeError, BytesWarning):
91 genericpath._check_arg_types('join', a, *p)
92 raise
93 return path
94
95
96# Split a path in head (everything up to the last '/') and tail (the

Callers 2

ismountFunction · 0.70
abspathFunction · 0.70

Calls 3

_get_sepFunction · 0.85
startswithMethod · 0.45
endswithMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…