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