MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / dirname

Function dirname

tools/python-3.11.9-amd64/Lib/posixpath.py:150–158  ·  view source on GitHub ↗

Returns the directory component of a pathname

(p)

Source from the content-addressed store, hash-verified

148# Return the head (dirname) part of a path, same as split(path)[0].
149
150def dirname(p):
151 """Returns the directory component of a pathname"""
152 p = os.fspath(p)
153 sep = _get_sep(p)
154 i = p.rfind(sep) + 1
155 head = p[:i]
156 if head and head != sep*len(head):
157 head = head.rstrip(sep)
158 return head
159
160
161# Is a path a symbolic link?

Callers

nothing calls this directly

Calls 3

_get_sepFunction · 0.85
rfindMethod · 0.80
rstripMethod · 0.45

Tested by

no test coverage detected