diff --git a/os.path/os/path.py b/os.path/os/path.py index aacd3277f..f34b5bd38 100644 --- a/os.path/os/path.py +++ b/os.path/os/path.py @@ -27,3 +27,11 @@ def exists(path): # TODO lexists = exists + +def isdir(path): + import stat + try: + mode = os.stat(path)[0] + return stat.S_ISDIR(mode) + except OSError: + return False diff --git a/os.path/test_path.py b/os.path/test_path.py index d0fd58fab..5cde0579a 100644 --- a/os.path/test_path.py +++ b/os.path/test_path.py @@ -6,3 +6,10 @@ assert split("/foo") == ("/", "foo") assert split("/foo/") == ("/foo", "") assert split("/foo/bar") == ("/foo", "bar") + +assert exists("test_path.py") +assert not exists("test_path.py--") + +assert isdir("os") +assert not isdir("os--") +assert not isdir("test_path.py")