On this page
genericpath.lexists
Prev: genericpath.islink | Up: genericpath | Next: genericpath.samefile
Rel: genericpath.commonprefix, genericpath.exists, genericpath.getatime, genericpath.getctime
Ref: docs.python.org — genericpath.lexists
Tags: #public #python3 #stdlib #genericpath
Import
import genericpath
from genericpath import lexists
Signature & Overview
genericpath.lexists(path)
Test whether a path exists. Returns True for broken symbolic links
Usage
import os
from pathlib import Path
import tempfile
with tempfile.TemporaryDirectory() as tmp:
link = Path(tmp) / "broken"
link.symlink_to(Path(tmp) / "missing_target")
assert os.path.lexists(link) is True and os.path.exists(link) is False
Gotchas
- Returns
Truefor broken symlinks (useslstatinstead ofstat).
REPL Inspect
from genericpath import lexists
help(lexists)
Linked from
Related notes
- tuts/python3/stdlib_module/genericpath/islink Linked here; links to this page; shared tags: #genericpath, #stdlib
- tuts/python3/stdlib_module/genericpath/samefile Linked here; links to this page; shared tags: #genericpath, #stdlib
- tuts/python3/stdlib_module/genericpath Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/genericpath/commonprefix Linked here; shared tags: #genericpath, #stdlib
- tuts/python3/stdlib_module/genericpath/exists Linked here; shared tags: #genericpath, #stdlib
- tuts/python3/stdlib_module/genericpath/getatime Linked here; shared tags: #genericpath, #stdlib
- tuts/python3/stdlib_module/genericpath/getctime Linked here; shared tags: #genericpath, #stdlib
- tuts/python3/stdlib_module/genericpath/getmtime shared tags: #genericpath, #stdlib
- tuts/python3/stdlib_module/genericpath/getsize shared tags: #genericpath, #stdlib
- tuts/python3/stdlib_module/genericpath/isdevdrive shared tags: #genericpath, #stdlib