Returns the final component of a pathname
(p)
| 138 | # Return the tail (basename) part of a path, same as split(path)[1]. |
| 139 | |
| 140 | def basename(p): |
| 141 | """Returns the final component of a pathname""" |
| 142 | p = os.fspath(p) |
| 143 | sep = _get_sep(p) |
| 144 | i = p.rfind(sep) + 1 |
| 145 | return p[i:] |
| 146 | |
| 147 | |
| 148 | # Return the head (dirname) part of a path, same as split(path)[0]. |