diff -r d53506fe31e1 Doc/library/pathlib.rst --- a/Doc/library/pathlib.rst Sat Jan 03 22:33:10 2015 -0600 +++ b/Doc/library/pathlib.rst Sun Jan 04 14:16:15 2015 +0530 @@ -628,6 +628,17 @@ PosixPath('/home/antoine/pathlib') +.. classmethod:: Path.home() + + Return a new path object representing the user's home directory (as + returned by :func:`os.path.expanduser` with ``~`` construct):: + + >>> Path.home() + PosixPath('/home/antoine') + + .. versionadded:: 3.5 + + .. method:: Path.stat() Return information about this path (similarly to :func:`os.stat`). diff -r d53506fe31e1 Lib/pathlib.py --- a/Lib/pathlib.py Sat Jan 03 22:33:10 2015 -0600 +++ b/Lib/pathlib.py Sun Jan 04 14:16:15 2015 +0530 @@ -1008,6 +1008,13 @@ """ return cls(os.getcwd()) + @classmethod + def home(cls): + """Return a new path pointing to the user's home directory (as + returned by os.path.expanduser('~')) + """ + return cls(cls()._flavour.gethomedir(None)) + 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)). diff -r d53506fe31e1 Lib/test/test_pathlib.py --- a/Lib/test/test_pathlib.py Sat Jan 03 22:33:10 2015 -0600 +++ b/Lib/test/test_pathlib.py Sun Jan 04 14:16:15 2015 +0530 @@ -1261,6 +1261,17 @@ p = self.cls.cwd() self._test_cwd(p) + def _test_home(self, p): + q = self.cls(os.path.expanduser('~')) + self.assertEqual(p, q) + self.assertEqual(str(p), str(q)) + self.assertIs(type(p), type(q)) + self.assertTrue(p.is_absolute()) + + def test_home(self): + p = self.cls.home() + self._test_home(p) + def test_samefile(self): fileA_path = os.path.join(BASE, 'fileA') fileB_path = os.path.join(BASE, 'dirB', 'fileB')