This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Implement pathlib.Path.append_bytes and pathlib.Path.append_text
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.8
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: keelung-yang, nuno, pitrou
Priority: normal Keywords: patch

Created on 2018-10-28 19:17 by pablogsal, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 10193 closed pablogsal, 2018-10-28 19:18
PR 3811 closed nuno, 2022-01-24 21:03
Messages (4)
msg328730 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2018-10-28 19:17
Right now we have:

Path.read_bytes
Path.read_text
Path.write_bytes
Path.write_text

as opening the file, appending something and closing the file is also a very typical operation to do it would be nice to have:

Path.append_bytes
Path.append_text
msg328858 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2018-10-29 19:53
First, it is quite uncommon to open a file in append mode.  Second, when you open in append mode, often you will gradually append (such as for a logfile), so a single method call isn't effective.

So I think this does not solve an important use case.
msg328859 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2018-10-29 19:58
Thanks @pitrou for the feedback!

As you think this will not be that useful, I will close the issue and the proposal PR.
msg411453 - (view) Author: Keelung Yang (keelung-yang) * Date: 2022-01-24 08:23
@pitrou
Firstly, I can't agree with `it is quite uncommon to open a file in append mode`. It should be depended to users and their application scenes.

@pablogsal
Secondly, I think `Path.write_*(, append=False)` is better then adding new APIs, as discussed in https://stackoverflow.com/questions/57296168/pathlib-path-write-text-in-append-mode
History
Date User Action Args
2022-04-11 14:59:07adminsetgithub: 79276
2022-01-24 21:08:02pablogsalsetnosy: - pablogsal
2022-01-24 21:03:43nunosetnosy: + nuno

pull_requests: + pull_request29041
2022-01-24 08:23:47keelung-yangsetnosy: + keelung-yang
messages: + msg411453
2018-10-29 19:58:17pablogsalsetstatus: open -> closed

messages: + msg328859
stage: patch review -> resolved
2018-10-29 19:53:16pitrousetmessages: + msg328858
2018-10-29 19:51:24pablogsalsetnosy: + pitrou
2018-10-28 19:18:12pablogsalsetkeywords: + patch
stage: patch review
pull_requests: + pull_request9512
2018-10-28 19:17:21pablogsalcreate