On this page
ntpath.dirname
Prev: ntpath.commonprefix | Up: ntpath | Next: ntpath.exists
Rel: ntpath.abspath, ntpath.basename, ntpath.commonpath, ntpath.commonprefix
Ref: docs.python.org — ntpath.dirname
Tags: #public #python3 #stdlib #ntpath
Import
import ntpath
from ntpath import dirname
Signature & Overview
ntpath.dirname(p)
Returns the directory component of a pathname
Usage
import ntpath
assert ntpath.dirname(r'C:\Users\Ada\doc.txt') == r'C:\Users\Ada'
Gotchas
- Pure string split: Does not normalize
..or resolve symlinks.
REPL Inspect
from ntpath import dirname
help(dirname)
Linked from
Related notes
- tuts/python3/stdlib_module/ntpath/abspath Linked here; links to this page; shared tags: #ntpath, #stdlib
- tuts/python3/stdlib_module/ntpath/basename 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/exists 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/expanduser shared tags: #ntpath, #stdlib
- tuts/python3/stdlib_module/ntpath/expandvars shared tags: #ntpath, #stdlib
- tuts/python3/stdlib_module/ntpath/getatime shared tags: #ntpath, #stdlib
- tuts/python3/stdlib_module/ntpath/getctime shared tags: #ntpath, #stdlib