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

Function dirname

Lib/posixpath.py:177–185  ·  view source on GitHub ↗

Returns the directory component of a pathname

(p, /)

Source from the content-addressed store, hash-verified

175# Return the head (dirname) part of a path, same as split(path)[0].
176
177def dirname(p, /):
178 """Returns the directory component of a pathname"""
179 p = os.fspath(p)
180 sep = _get_sep(p)
181 i = p.rfind(sep) + 1
182 head = p[:i]
183 if head and head != sep*len(head):
184 head = head.rstrip(sep)
185 return head
186
187
188# Is a path a mount point?

Calls 3

_get_sepFunction · 0.85
rfindMethod · 0.45
rstripMethod · 0.45

Used in the wild real call sites across dependent graphs

searching dependent graphs…