Title: Add optional user argument to pathlib.Path.home()
Type: Stage:
Components: Library (Lib) Versions: Python 3.7
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: josh.r, serhiy.storchaka
Priority: normal Keywords:

Created on 2016-10-19 17:34 by josh.r, last changed 2016-10-19 18:17 by serhiy.storchaka.

Messages (2)
msg278988 - (view) Author: Josh Rosenberg (josh.r) * (Python triager) Date: 2016-10-19 17:34
os.path.expanduser supports both '~' and '~username` constructs to get home directories. It seems reasonable for pathlib.Path.home to default to getting the current user's home directory, but support passing an argument to get the home directory for another user. It means no need to use os.path.expanduser for the purpose (which always strikes me as a little "ugly" for portable code; the ~ works, but it's using UNIX syntax in a way that makes it feel non-portable), making pathlib a more complete replacement.
msg278989 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-10-19 18:17
pathlib.Path.home() don't support the user argument for reasons.

The main problem is that os.path.expanduser() for other users is faked on Windows. It uses guessing, and perhaps it returns correct result in most cases. But in non-standard situations, if current user or other users have non-default home directory, it returns wrong result. I don't know wherever it works for users with non-ascii names or names containing special characters.
Date User Action Args
2016-10-19 18:17:27serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg278989
2016-10-19 17:34:22josh.rcreate