Christopher Welborn added the comment:

Antoine said:
> I would suggest differently:
> - read_text(encoding, errors, newline)
> - read_bytes()
> - write_text(data, encoding, errors, newline)
> - write_bytes(data)
>
> Strictly speaking, write() could be polymorphic, but I think it's nice
> to have distinct methods 1) out of symmetry with read*() 2) to avoid
> silently accepting the wrong type.

I am starting to see where you are going with this, and I agree with your 
latest points.

I dropped readlines/writelines. I guess pathlib doesn't have to do *exactly* 
everything you can do through normal io. They are easy to implement anyway with 
.split() and .join().

I realize this would not make it into Python for a while (3.5 possibly, if at 
all), but I went ahead and made a patch anyway because I have time to do so at 
the moment.

I updated the tests to reflect the latest changes, and made sure all of them 
still pass. Any criticism/wisdom would be appreciated, as this is my first time 
dealing with the Python patch process.

The api is what you have, except I put an 'append' option:
    read_bytes()
    read_text(encoding=None, errors=None, newline=None)
    write_bytes(data, append=False)
    write_text(data, encoding=None, errors=None, newline=None, append=False)

----------
Added file: http://bugs.python.org/file33670/pathlib.readwrite3.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue20218>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to