Message209029
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) |
|
Date |
User |
Action |
Args |
2014-01-24 01:15:39 | cjwelborn | set | recipients:
+ cjwelborn, pitrou, cool-RR, serhiy.storchaka |
2014-01-24 01:15:33 | cjwelborn | set | messageid: <1390526133.85.0.414172521235.issue20218@psf.upfronthosting.co.za> |
2014-01-24 01:15:33 | cjwelborn | link | issue20218 messages |
2014-01-24 01:15:31 | cjwelborn | create | |
|