From 17cba7daf5cdbe2a0e589be9ef507408b8dc07f1 Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Mon, 12 Jan 2015 21:03:41 +0100 Subject: Issue #19777: Provide a home() classmethod on Path objects. Contributed by Victor Salgado and Mayank Tripathi. --- Lib/pathlib.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'Lib/pathlib.py') diff --git a/Lib/pathlib.py b/Lib/pathlib.py index 6244932482..dd2ccba1a6 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)). -- cgit v1.2.1