diff options
author | Johannes Gijsbers <jlg@dds.nl> | 2004-08-30 10:19:56 (GMT) |
---|---|---|
committer | Johannes Gijsbers <jlg@dds.nl> | 2004-08-30 10:19:56 (GMT) |
commit | ae882f798435266b41a9c8966562102345a3eda5 (patch) | |
tree | 56f865bf36c127b6702fa53a5ad72daca0fa6570 /Lib/posixpath.py | |
parent | d3f61a2de6a9664dde5f98b5d0acdef7a73948dc (diff) | |
download | cpython-ae882f798435266b41a9c8966562102345a3eda5.zip cpython-ae882f798435266b41a9c8966562102345a3eda5.tar.gz cpython-ae882f798435266b41a9c8966562102345a3eda5.tar.bz2 |
Patch #941486: add os.path.lexists(). Also fix bug #940578 by using lexists in glob.glob.
Diffstat (limited to 'Lib/posixpath.py')
-rw-r--r-- | Lib/posixpath.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/posixpath.py b/Lib/posixpath.py index 1a25934..b29eedc 100644 --- a/Lib/posixpath.py +++ b/Lib/posixpath.py @@ -174,6 +174,17 @@ def exists(path): return True +# Being true for dangling symbolic links is also useful. + +def lexists(path): + """Test whether a path exists. Returns True for broken symbolic links""" + try: + st = os.lstat(path) + except os.error: + return False + return True + + # Is a path a directory? # This follows symbolic links, so both islink() and isdir() can be true # for the same path. |