[New-bugs-announce] [issue37255] Pathlib: Add an expandUserPath method or argument

Andrea Moro report at bugs.python.org
Wed Jun 12 12:49:14 EDT 2019


New submission from Andrea Moro <andrea.moro at rs-components.com>:

Assuming the given path contains a '~' character, it would be nice to have a function to expand the given path so any further calls to an .exists doesn't fail.

A prototype of the function could be

        # Expand the home path in *ix based systems if any
        if '~' in s:
            x = [x for x in Path(s).parts if x not in '~']
            p = Path.home()
            for item in x:
                p = p.joinpath(item)

----------
components: Library (Lib)
messages: 345379
nosy: Andrea Moro
priority: normal
severity: normal
status: open
title: Pathlib: Add an expandUserPath method or argument
type: enhancement

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


More information about the New-bugs-announce mailing list