Skip to content

Add kw argument parents to pathlib.Path.touch #138047

@swaldhoer

Description

@swaldhoer

Feature or enhancement

Proposal:

I would be nice when

from pathlib import Path
my_dir = Path("foo/bar")
my_dir.mkdir(exist_ok=True, parents=True)
my_file = my_dir / "bla.txt"
my_file .touch()

could be written as

from pathlib import Path
my_file = Path("foo/bar/bla.txt")
my_file.touch(parents=True)

Default function signature should be changed from
Path.touch(mode=0o666, exist_ok=True)
for backwards combability to
Path.touch(mode=0o666, exist_ok=True, parents=False)

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions