Christopher Welborn added the comment:
Isn't this something you could do yourself?
import pathlib
def pathread(self, binary=False):
with self.open('br'if binary else 'r') as fread:
return fread.read()
def pathwrite(self, data, mode='w'):
with self.open(mode) as fwrite:
fwrite.write(data)
pathlib.Path.read = pathread
pathlib.Path.write = pathwrite
p = pathlib.Path('/mydir/example.txt')
p.read()
# 'Content from path.\n'
p.write('I am appending.\n', mode='a')
p.read()
# 'Content from path.\nI am appending.\n'
...and what about:
"There should be one-- and preferably only one --obvious way to do it."
----------
nosy: +cjwelborn
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue20218>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com