diff -r 0387054b2038 Lib/pathlib.py --- a/Lib/pathlib.py Sat Nov 30 19:04:00 2013 -0800 +++ b/Lib/pathlib.py Sun Dec 01 12:57:39 2013 +0800 @@ -948,6 +948,12 @@ """ return cls(os.getcwd()) + def samefile(self, other_file): + """Return whether `other_file` is same or not with this file. + (as returned by os.path.samefile(file, other_file)). + """ + return os.path.samefile(str(self.resolve()), other_file) + def iterdir(self): """Iterate over the files in this directory. Does not yield any result for the special paths '.' and '..'. diff -r 0387054b2038 Lib/test/test_pathlib.py --- a/Lib/test/test_pathlib.py Sat Nov 30 19:04:00 2013 -0800 +++ b/Lib/test/test_pathlib.py Sun Dec 01 12:57:39 2013 +0800 @@ -1129,6 +1129,13 @@ p = self.cls.cwd() self._test_cwd(p) + def test_samefile(self): + fileA_path = os.path.join(BASE, 'fileA') + fileB_path = os.path.join(BASE, 'dirB', 'fileB') + p = self.cls(fileA_path) + self.assertTrue(p.samefile(fileA_path)) + self.assertFalse(p.samefile(fileB_path)) + def test_empty_path(self): # The empty path points to '.' p = self.cls('')