Issue #19777: Provide a home() classmethod on Path objects.

Contributed by Victor Salgado and Mayank Tripathi.
This commit is contained in:
Antoine Pitrou 2015-01-12 21:03:41 +01:00
parent 2b4ec1ce8a
commit 17cba7daf5
5 changed files with 34 additions and 0 deletions

View file

@ -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)).