Returns the directory component of a pathname
(p, /)
| 175 | # Return the head (dirname) part of a path, same as split(path)[0]. |
| 176 | |
| 177 | def 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? |
searching dependent graphs…