Author pitrou
Recipients cjwelborn, cool-RR, pitrou, serhiy.storchaka
Date 2014-01-23.23:16:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1390518995.2293.37.camel@fsol>
In-reply-to <1390512798.7.0.597197950615.issue20218@psf.upfronthosting.co.za>
Content
> 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().
History
Date User Action Args
2014-01-23 23:16:41pitrousetrecipients: + pitrou, cool-RR, serhiy.storchaka, cjwelborn
2014-01-23 23:16:41pitroulinkissue20218 messages
2014-01-23 23:16:39pitroucreate