[New-bugs-announce] [issue42998] pathlib.Path: add `username` argument to `home()`

Barney Gale report at bugs.python.org
Thu Jan 21 22:57:15 EST 2021


New submission from Barney Gale <barney.gale at gmail.com>:

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 cls(cls()._flavour.gethomedir(None))

If we add a `username=None` parameter and pass this to `gethomedir()` we can easily add a lookup of another user's home directory, so:

    import pathlib
    username = 'phil'
    pathlib.Path.home(username) == pathlib.Path('~' + username).expanduser()

----------
components: Library (Lib)
messages: 385472
nosy: barneygale
priority: normal
severity: normal
status: open
title: pathlib.Path: add `username` argument to `home()`
type: enhancement

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42998>
_______________________________________


More information about the New-bugs-announce mailing list