Skip to content

os.expandTilde "~user" support #24655

Open
@litlighilit

Description

@litlighilit

Summary

os.expandTilde may support "~user", in addition to path beginning with "~"

Description

Python's os.path.expanduser support both '~' and '~user'

And there's a TODO in source code of os.expandTilde:

    # TODO: handle `~bob` and `~bob/` which means home of bob

Also, if ~user cannot be replaced, the path will be returned AS-IS.

Alternatives

No response

Examples

import std/os
echo os.expandTilde("~root")

Backwards Compatibility

This is an expansion to the previous procedure.

A few path that didn't be expanded will be.

Links

https://docs.python.org/3/library/os.path.html#os.path.expanduser

A todo in issue #8177 make extractFilename("~bob") work

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions