On this page
ntpath.basename
Prev: ntpath.abspath | Up: ntpath | Next: ntpath.commonpath
Rel: ntpath.abspath, ntpath.commonpath, ntpath.commonprefix, ntpath.dirname
Ref: docs.python.org — ntpath.basename
Tags: #public #python3 #stdlib #ntpath
Import
import ntpath
from ntpath import basename
Signature & Overview
ntpath.basename(p)
Returns the final component of a pathname
Usage
import ntpath
assert ntpath.basename(r'C:\Users\Ada\doc.txt') == 'doc.txt'
Gotchas
- Trailing backslash returns
'':ntpath.basename(r'C:\Users\')is''.
REPL Inspect
from ntpath import basename
help(basename)
Linked from
- tuts/python3/stdlib_module/ntpath
- tuts/python3/stdlib_module/ntpath/abspath
- tuts/python3/stdlib_module/ntpath/commonpath
- tuts/python3/stdlib_module/ntpath/commonprefix
- tuts/python3/stdlib_module/ntpath/dirname
- tuts/python3/stdlib_module/ntpath/exists
- tuts/python3/stdlib_module/ntpath/expanduser
- tuts/python3/stdlib_module/ntpath/expandvars
- tuts/python3/stdlib_module/ntpath/getatime
- tuts/python3/stdlib_module/ntpath/getctime
- tuts/python3/stdlib_module/ntpath/getmtime
- tuts/python3/stdlib_module/ntpath/getsize
- tuts/python3/stdlib_module/ntpath/isabs
- tuts/python3/stdlib_module/ntpath/isdevdrive
- tuts/python3/stdlib_module/ntpath/isdir
- tuts/python3/stdlib_module/ntpath/isfile
- tuts/python3/stdlib_module/ntpath/isjunction
- tuts/python3/stdlib_module/ntpath/islink
- tuts/python3/stdlib_module/ntpath/ismount
- tuts/python3/stdlib_module/ntpath/isreserved
- tuts/python3/stdlib_module/ntpath/join
- tuts/python3/stdlib_module/ntpath/lexists
- tuts/python3/stdlib_module/ntpath/normcase
- tuts/python3/stdlib_module/ntpath/normpath
- tuts/python3/stdlib_module/ntpath/realpath
- tuts/python3/stdlib_module/ntpath/relpath
- tuts/python3/stdlib_module/ntpath/samefile
- tuts/python3/stdlib_module/ntpath/sameopenfile
- tuts/python3/stdlib_module/ntpath/samestat
- tuts/python3/stdlib_module/ntpath/split
- tuts/python3/stdlib_module/ntpath/splitdrive
- tuts/python3/stdlib_module/ntpath/splitext
- tuts/python3/stdlib_module/ntpath/splitroot
Related notes
- tuts/python3/stdlib_module/ntpath/abspath Linked here; links to this page; shared tags: #ntpath, #stdlib
- tuts/python3/stdlib_module/ntpath/commonpath Linked here; links to this page; shared tags: #ntpath, #stdlib
- tuts/python3/stdlib_module/ntpath/commonprefix Linked here; links to this page; shared tags: #ntpath, #stdlib
- tuts/python3/stdlib_module/ntpath/dirname Linked here; links to this page; shared tags: #ntpath, #stdlib
- tuts/python3/stdlib_module/ntpath Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/ntpath/exists links to this page; shared tags: #ntpath, #stdlib
- tuts/python3/stdlib_module/ntpath/expanduser links to this page; shared tags: #ntpath, #stdlib
- tuts/python3/stdlib_module/ntpath/expandvars links to this page; shared tags: #ntpath, #stdlib
- tuts/python3/stdlib_module/ntpath/getatime links to this page; shared tags: #ntpath, #stdlib
- tuts/python3/stdlib_module/ntpath/getctime links to this page; shared tags: #ntpath, #stdlib