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.

Author barneygale
Recipients barneygale, keelung-yang
Date 2022-01-27.22:05:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1643321145.98.0.0605544792633.issue46554@roundup.psfhosted.org>
In-reply-to
Content
From https://stackoverflow.com/a/68969892

> I think a major reason why pathlib.Path objects don't (and, indeed,
> shouldn't) have a append_text method is because it creates a hole for
> inexperienced users to fall into, which is a huge sin in API design.

> Specifically, the hole I'm referring to is using append_text on the
> same file repeatedly in a loop. Because you're continually opening
> and closing the file, it is slow. Plus, doing so many unnecessary
> writes is probably not great for the health of your hard drive.

> Worse, because the program will actually behave correctly (e.g. the
> file will have the contents they intended), they may not even notice
> anything is wrong, because they don't necessarily have a mental gauge
> on how long writing to a file "should" take.

Most of the time you don't need an 'append' mode. And when you do, most
of the time you'll need to append multiple times, in which case
`path.open('a')` is a much better bet.
History
Date User Action Args
2022-01-27 22:05:46barneygalesetrecipients: + barneygale, keelung-yang
2022-01-27 22:05:45barneygalesetmessageid: <1643321145.98.0.0605544792633.issue46554@roundup.psfhosted.org>
2022-01-27 22:05:45barneygalelinkissue46554 messages
2022-01-27 22:05:45barneygalecreate