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

Function split

Lib/posixpath.py:101–110  ·  view source on GitHub ↗

Split a pathname. Returns 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

99# Trailing '/'es are stripped from head unless it is the root.
100
101def split(p, /):
102 """Split a pathname. Returns tuple "(head, tail)" where "tail" is
103 everything after the final slash. Either part may be empty."""
104 p = os.fspath(p)
105 sep = _get_sep(p)
106 i = p.rfind(sep) + 1
107 head, tail = p[:i], p[i:]
108 if head and head != sep*len(head):
109 head = head.rstrip(sep)
110 return head, tail
111
112
113# Split a path in root and extension.

Callers

nothing calls this directly

Calls 3

_get_sepFunction · 0.85
rfindMethod · 0.45
rstripMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…