Barney Gale <[email protected]> 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, `os.getcwd()` is a more fundamental operation than
`os.path.absolute()`. In both pathlib and os.path, the `absolute()`
implementation is built on the `getcwd()` implementation. The process is: call
the more fundamental operation, and append whatever else was passed as an
argument.
Analagously, `gethomedir()` is a more fundamental operation than
`expanduser()`. In the same way, `expanduser()` can call a more fundamental
operation and then append the path passed in.
Secondly, for a `pathlib.AbstractPath` implementation, it's a much cleaner API
to have `getcwd()` and `gethomedir()` as abstract methods with identical
signatures, and `absolute()` and `expanduser()` with default implementations.
Thirdly, if there's are issues with the implementation for retrieving other
user's home directories, those should be treated as individual issues with
their own bugs, and we should add suitable warnings in the docs in the short
term. My patch should make these cases *easier* to solve as we no longer have
two competing implementations of the same thing.
Finally, I don't think anyone is going to see `home('barney')` in the docs and
decided to retrieve a user's home directory on a whim. If someone *does* need
to retrieve another user's home directory, they're going to use `Path('~' +
user).expanduser()` if `Path.home(user)` isn't available.
My argument mostly comes from the similarities I perceive between
getcwd/absolute and gethomedir/expanduser. We don't expect users to
`os.path.absolute('.')` to get the current working directory, after all! But
perhaps I've overestimated the similarities here. Any thoughts?
Thanks again for taking a look.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue42998>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com