mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue #19777: Provide a home() classmethod on Path objects.
Contributed by Victor Salgado and Mayank Tripathi.
This commit is contained in:
parent
2b4ec1ce8a
commit
17cba7daf5
5 changed files with 34 additions and 0 deletions
|
@ -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)).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue