MCPcopy Index your code
hub / github.com/RustPython/RustPython / dirname

Function dirname

Lib/posixpath.py:176–184  ·  view source on GitHub ↗

Returns the directory component of a pathname

(p)

Source from the content-addressed store, hash-verified

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

Calls 4

_get_sepFunction · 0.85
lenFunction · 0.85
rfindMethod · 0.45
rstripMethod · 0.45