[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:

    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>

More information about the New-bugs-announce mailing list