[Python-ideas] `pathlib.Path.write` and `pathlib.Path.read`
Ram Rachum
ram.rachum at gmail.com
Sat Jan 4 23:41:01 CET 2014
Hi,
I'd really like to have methods `pathlib.Path.write` and
`pathlib.Path.read`. Untested implementation:
def read(self, binary=False):
with self.open('br' is binary else 'r') as file:
return file.read()
def write(self, data. binary=False):
with self.open('bw' is binary else 'w') as file:
file.write(data)
This will be super useful to me. Many files actions are one liners like
that, and avoiding putting the `with` clause in user code would be
wonderful.
What do you think?
Thanks,
Ram.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140104/e324e397/attachment.html>
More information about the Python-ideas
mailing list