Returns the final component of a pathname
(p, /)
| 165 | # Return the tail (basename) part of a path, same as split(path)[1]. |
| 166 | |
| 167 | def basename(p, /): |
| 168 | """Returns the final component of a pathname""" |
| 169 | p = os.fspath(p) |
| 170 | sep = _get_sep(p) |
| 171 | i = p.rfind(sep) + 1 |
| 172 | return p[i:] |
| 173 | |
| 174 | |
| 175 | # Return the head (dirname) part of a path, same as split(path)[0]. |
searching dependent graphs…