Message209017
> One thing I am not seeing is a readlines/writelines in these two
> libaries. I still think they would be useful, even without the size
> argument for readlines.
readlines() and writelines() aren't used a lot in my experience.
> So this is what I am seeing now:
> read_text(encoding=None)
> readlines_text(encoding=None) ..(or read_textlines?)
> read_bytes()
> readlines_bytes()
> write(data, append=False) ..(mode is decided based on data type)
> writelines(lines, append=False)
>
> ..determining the mode for writelines looks at the first item's type?
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.
As a reference, https://github.com/mikeorr/Unipath (which is quite
popular) has read_file() and write_file() methods.
https://github.com/jaraco/path.py has bytes(), text(), write_bytes() and
write_text(). |
|
Date |
User |
Action |
Args |
2014-01-23 23:16:41 | pitrou | set | recipients:
+ pitrou, cool-RR, serhiy.storchaka, cjwelborn |
2014-01-23 23:16:41 | pitrou | link | issue20218 messages |
2014-01-23 23:16:39 | pitrou | create | |
|