On this page
posixpath.dirname
Prev: posixpath.commonprefix | Up: posixpath | Next: posixpath.exists
Rel: posixpath.abspath, posixpath.basename, posixpath.commonpath, posixpath.commonprefix
Ref: docs.python.org — posixpath.dirname
Tags: #public #python3 #stdlib #posixpath
Import
import posixpath
from posixpath import dirname
Signature & Overview
posixpath.dirname(p)
Returns the directory component of a pathname
Usage
import posixpath
assert posixpath.dirname('/usr/local/bin') == '/usr/local'
Gotchas
- Pure lexical split: Does not check the filesystem.
REPL Inspect
from posixpath import dirname
help(dirname)
Linked from
Related notes
- tuts/python3/stdlib_module/posixpath/abspath Linked here; links to this page; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/basename Linked here; links to this page; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/commonpath Linked here; links to this page; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/commonprefix Linked here; links to this page; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/exists Linked here; links to this page; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/posixpath/expanduser shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/expandvars shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/getatime shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/getctime shared tags: #posixpath, #stdlib