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

Function split

Lib/ntpath.py:222–235  ·  view source on GitHub ↗

Split a pathname. Return tuple (head, tail) where tail is everything after the final slash. Either part may be empty.

(p, /)

Source from the content-addressed store, hash-verified

220# The resulting head won't end in '/' unless it is the root.
221
222def split(p, /):
223 """Split a pathname.
224
225 Return tuple (head, tail) where tail is everything after the final slash.
226 Either part may be empty."""
227 p = os.fspath(p)
228 seps = _get_bothseps(p)
229 d, r, p = splitroot(p)
230 # set i to index beyond p's last slash
231 i = len(p)
232 while i and p[i-1] not in seps:
233 i -= 1
234 head, tail = p[:i], p[i:] # now tail has no slashes
235 return d + r + head.rstrip(seps), tail
236
237
238# Split a path in root and extension.

Callers 5

readconfigFunction · 0.90
basenameFunction · 0.70
dirnameFunction · 0.70
realpathFunction · 0.70

Calls 3

splitrootFunction · 0.90
_get_bothsepsFunction · 0.85
rstripMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…