[issue42998] pathlib.Path: add `username` argument to `home()`

2021-06-13 Thread Barney Gale
Barney Gale added the comment: Per discussion, expanduser('~other') is considered unreliable, and we shouldn't add new functions that call through to it. Resolving as 'rejected'. -- resolution: -> rejected stage: patch review -> resolved status: open -> closed

[issue42998] pathlib.Path: add `username` argument to `home()`

2021-04-28 Thread Barney Gale
Barney Gale added the comment: So far I've been keen to keep the Path and AbstractPath APIs the same, but perhaps this case warrants an exception. What if AbstractPath lacked both home() and expanduser(), and those methods only existed on Path? Of all the methods on Path, these two are the

[issue42998] pathlib.Path: add `username` argument to `home()`

2021-04-26 Thread Barney Gale
Barney Gale added the comment: Totally valid! I suppose it hinges on the relatively likelihood/unlikelihood of us being able to make `expanduser('~foo')` reliable in future. On this question I'm relieved to defer to the experts! @eryksun: penny for your thoughts? --

[issue42998] pathlib.Path: add `username` argument to `home()`

2021-04-26 Thread Steve Dower
Steve Dower added the comment: Yeah, that's all reasonable. But why wouldn't we go the other way and say "getting a user directory for a different user is not supported and all existing ways to do it are now deprecated"? I know you think that's not a relevant argument right now, but it is

[issue42998] pathlib.Path: add `username` argument to `home()`

2021-04-26 Thread Barney Gale
Barney Gale added the comment: In the previous comment, I was referring to bpo-39899 when I referred to "my patch". Long day! :D -- ___ Python tracker ___

[issue42998] pathlib.Path: add `username` argument to `home()`

2021-04-26 Thread Barney Gale
Barney Gale added the comment: Thanks very much for taking a look. I can understand the view that, given the unreliability of `os.path.expanduser('~foo')`, we shouldn't be making that functionality *more* available. My argument for this being a reasonable change is as follows: Firstly,

[issue42998] pathlib.Path: add `username` argument to `home()`

2021-04-26 Thread Steve Dower
Steve Dower added the comment: I'm not convinced this is a good change, mainly for the reasons Serhiy mentioned (and others have mentioned when I've spoken with them privately). What would you do with your custom subclass if home() did not have this argument? -- nosy: +steve.dower

[issue42998] pathlib.Path: add `username` argument to `home()`

2021-04-08 Thread Eryk Sun
Eryk Sun added the comment: > 3. Worth fixing in `ntpath.expanduser()` To expand on the suggestion in msg390507, here's a demo that implements getting the profile path of a local user account, with support for the special profile directories "Default", "Public", and "ProgramData" (i.e.

[issue42998] pathlib.Path: add `username` argument to `home()`

2021-04-08 Thread Barney Gale
Barney Gale added the comment: Thanks for the feedback. 1. We can check the return value, like we do in `Path.expanduser()` 2. Seems like expected behaviour? 3. Worth fixing in `ntpath.expanduser()` I think. See Eryk Sun's comment here: https://bugs.python.org/issue39899#msg390507

[issue42998] pathlib.Path: add `username` argument to `home()`

2021-04-08 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: os.path.expanduser() has flaws. 1. It can return an argument unchanged if failed to determine the home directory. 2. On Unix it does not work for users not found in the local password database. 3. On Windows it only guess the home directory for other

[issue42998] pathlib.Path: add `username` argument to `home()`

2021-04-07 Thread Barney Gale
Change by Barney Gale : -- keywords: +patch pull_requests: +24004 stage: -> patch review pull_request: https://github.com/python/cpython/pull/25271 ___ Python tracker ___

[issue42998] pathlib.Path: add `username` argument to `home()`

2021-01-21 Thread Barney Gale
Barney Gale added the comment: I should add that this is part of a plan to spin out some `Path` methods into a new `UserPath` class. Notably, in this case, `UserPath.expanduser()` will call `self.home()` under-the-hood. This is done to reduce the surface area of abstract methods that

[issue42998] pathlib.Path: add `username` argument to `home()`

2021-01-21 Thread Barney Gale
New submission from Barney Gale : The `pathlib.Path.home()` function looks like: @classmethod def home(cls): """Return a new path pointing to the user's home directory (as returned by os.path.expanduser('~')). """ return