Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions python-stdlib/os-path/os/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ def isdir(path):
return False


def isfile(path):
try:
return bool(os.stat(path)[0] & 0x8000)
except OSError:
return False


def expanduser(s):
if s == "~" or s.startswith("~/"):
h = os.getenv("HOME")
Expand Down
4 changes: 4 additions & 0 deletions python-stdlib/os-path/test_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@
assert isdir(dir + "/os")
assert not isdir(dir + "/os--")
assert not isdir(dir + "/test_path.py")

assert not isfile(dir + "/os")
assert isfile(dir + "/test_path.py")
assert not isfile(dir + "/test_path.py--")