This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author abarnert
Recipients Douglas.Alan, abarnert, amaury.forgeotdarc, benjamin.peterson, eric.araujo, facundobatista, georg.brandl, jcon, ncoghlan, nessus42, pitrou, r.david.murray, ralph.corderoy, rhettinger, ysj.ray
Date 2014-07-20.00:07:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1405814825.52.0.151408170703.issue1152248@psf.upfronthosting.co.za>
In-reply-to
Content
http://thread.gmane.org/gmane.comp.python.ideas/28310 discusses the same idea.

Guido raised a serious problem with either adding an argument to readline and friends, or adding new methods readrecord and friends: It means the hundreds of existing file-like objects that exist today no longer meet the file API.

Putting the separator in the constructor call solves that problem. Construction is not part of the file API, and different file-like objects' constructors are already wildly different. It also seems to fit in better with what perl, awk, bash, etc. do (whether you either set something globally, or on the file, rather than on the line-reading mechanism). And it seems conceptually cleaner; a file shouldn't be changing line-endings in mid-stream—and if it does, that's similar to changing encodings.

Whether this should be done by reusing newline, or by adding another new parameter, I'm not sure. The biggest issue with reusing newline is that it has a meaning for write mode, not just for read mode (either terminal \n characters, or all \n characters, it's not entire clear which, are replaced with newline), and I'm not sure that's appropriate here. (Or, worse, maybe it's appropriate for text files but not binary files?)

R. David Murray's patch doesn't handle binary files, or _pyio, and IIRC from testing the same thing there was one more problem to fix for text files as well… but it's not hard to complete. If I have enough free time tomorrow, I'll clean up what I have and post it.
History
Date User Action Args
2014-07-20 00:07:05abarnertsetrecipients: + abarnert, georg.brandl, rhettinger, facundobatista, amaury.forgeotdarc, ncoghlan, pitrou, benjamin.peterson, nessus42, eric.araujo, ralph.corderoy, r.david.murray, ysj.ray, Douglas.Alan, jcon
2014-07-20 00:07:05abarnertsetmessageid: <1405814825.52.0.151408170703.issue1152248@psf.upfronthosting.co.za>
2014-07-20 00:07:05abarnertlinkissue1152248 messages
2014-07-20 00:07:04abarnertcreate