mirror of
https://github.com/python/cpython.git
synced 2025-09-02 23:18:25 +00:00
Issue #19775: Add a samefile() method to pathlib Path objects.
Initial patch by Vajrasky Kok.
This commit is contained in:
parent
38acd4c028
commit
43e3d9409d
4 changed files with 53 additions and 0 deletions
|
@ -961,6 +961,17 @@ class Path(PurePath):
|
|||
"""
|
||||
return cls(os.getcwd())
|
||||
|
||||
def samefile(self, other_path):
|
||||
"""Return whether `other_file` is the same or not as this file.
|
||||
(as returned by os.path.samefile(file, other_file)).
|
||||
"""
|
||||
st = self.stat()
|
||||
try:
|
||||
other_st = other_path.stat()
|
||||
except AttributeError:
|
||||
other_st = os.stat(other_path)
|
||||
return os.path.samestat(st, other_st)
|
||||
|
||||
def iterdir(self):
|
||||
"""Iterate over the files in this directory. Does not yield any
|
||||
result for the special paths '.' and '..'.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue