diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2015-01-12 20:03:41 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2015-01-12 20:03:41 (GMT) |
commit | 17cba7daf5cdbe2a0e589be9ef507408b8dc07f1 (patch) | |
tree | 05b7922431dd4d704e4be6b4555bfd4e06dcfd62 /Lib/pathlib.py | |
parent | 2b4ec1ce8a1e14a0c8de4fbab9442c6260a5f27d (diff) | |
download | cpython-17cba7daf5cdbe2a0e589be9ef507408b8dc07f1.zip cpython-17cba7daf5cdbe2a0e589be9ef507408b8dc07f1.tar.gz cpython-17cba7daf5cdbe2a0e589be9ef507408b8dc07f1.tar.bz2 |
Issue #19777: Provide a home() classmethod on Path objects.
Contributed by Victor Salgado and Mayank Tripathi.
Diffstat (limited to 'Lib/pathlib.py')
-rw-r--r-- | Lib/pathlib.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/pathlib.py b/Lib/pathlib.py index 6244932..dd2ccba 100644 --- a/Lib/pathlib.py +++ b/Lib/pathlib.py @@ -1008,6 +1008,13 @@ class Path(PurePath): """ 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)). |