Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PurePath.with_stem() #84329

Closed
timhoffm mannequin opened this issue Apr 2, 2020 · 4 comments
Closed

Add PurePath.with_stem() #84329

timhoffm mannequin opened this issue Apr 2, 2020 · 4 comments
Labels
3.9 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@timhoffm
Copy link
Mannequin

timhoffm mannequin commented Apr 2, 2020

BPO 40148
Nosy @brettcannon, @pitrou, @timhoffm
PRs
  • bpo-40148 Add PurePath.with_stem() #19295
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2020-04-19.15:30:07.552>
    created_at = <Date 2020-04-02.00:40:24.877>
    labels = ['type-feature', 'library', '3.9']
    title = 'Add PurePath.with_stem()'
    updated_at = <Date 2020-12-27.01:42:41.890>
    user = 'https://github.com/timhoffm'

    bugs.python.org fields:

    activity = <Date 2020-12-27.01:42:41.890>
    actor = 'tinyaoqi'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-04-19.15:30:07.552>
    closer = 'pitrou'
    components = ['Library (Lib)']
    creation = <Date 2020-04-02.00:40:24.877>
    creator = 'timhoffm'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 40148
    keywords = ['patch']
    message_count = 4.0
    messages = ['365540', '365608', '366785', '383834']
    nosy_count = 4.0
    nosy_names = ['brett.cannon', 'pitrou', 'timhoffm', 'tinyaoqi']
    pr_nums = ['19295']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue40148'
    versions = ['Python 3.9']

    @timhoffm
    Copy link
    Mannequin Author

    timhoffm mannequin commented Apr 2, 2020

    Similar to PurePath.with_name() and PurePath.with_suffix() there should be a PurePath.with_stem().

    A common use case would be appending something before the suffix: path.with_stem(path.stem + '_v2')

    As of now this must be written more cumbersome as:
    path.with_name(path.stem + '_v2' + path.suffix)

    @timhoffm timhoffm mannequin added the stdlib Python modules in the Lib dir label Apr 2, 2020
    @SilentGhost SilentGhost mannequin added 3.9 only security fixes type-feature A feature request or enhancement labels Apr 2, 2020
    @brettcannon
    Copy link
    Member

    I personally would rather not add more methods that are doing simple string manipulations.

    @pitrou
    Copy link
    Member

    pitrou commented Apr 19, 2020

    New changeset 8aea4b3 by Tim Hoffmann in branch 'master':
    bpo-40148: Add PurePath.with_stem() (GH-19295)
    8aea4b3

    @pitrou pitrou closed this as completed Apr 19, 2020
    @pitrou pitrou closed this as completed Apr 19, 2020
    @tinyaoqi
    Copy link
    Mannequin

    tinyaoqi mannequin commented Dec 27, 2020

    In Pathlib, we have functions "with_name()""with_stem()""with_suffix()" to modify the file name in the path.

    In bpo-21798:"Allow adding Path or str to Path", it actually also want to modify the file name, that is "appand string to file name".

    if with_stem() more cumbersome as:
    path.with_name(path.stem + '_v2' + path.suffix)

    why not have a function with_xxxx() more cumbersome as:
    path.with_name(path.name + "_name.dat")

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants