pathlib Path `write_text` in append mode
10:41 31 Jul 2019

Is there a shortcut for python pathlib.Path objects to write_text() in append mode?

The standard open() function has mode="a" to open a file for writing and appending to the file if that file exists, and a Paths .open() function seems to have the same functionality (my_path.open("a")).

But what about the handy .write_text('..') shortcut, is there a way to use pathlib to open and append to a file with just doing the same things as with open()?

For clarity, I can do

with my_path.open('a') as fp:
    fp.write('my text')

but is there another way?

my_path.write_text('my text', mode='a')

python python-3.x pathlib