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.

classification
Title: Add separator argument to readline()
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: akira, bescoto, loewis
Priority: normal Keywords:

Created on 2002-06-02 08:04 by bescoto, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Messages (3)
msg11016 - (view) Author: Ben Escoto (bescoto) Date: 2002-06-02 08:04
This has probably been suggested previously because it
is so simple, but how about adding a second optional
argument to readline()?  If present, the second
argument would be a string (or possibly just a single
character) that marks the end of each line.  The
default is obviously '\n'. 

This scheme seems natural enough to me, and would
really help when parsing files with null terminated
lines.  There must be a lot of other uses too.

msg11017 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002-06-02 13:01
Logged In: YES 
user_id=21627

That's not simple at all. Python uses the C library's fgets
function on some systems, which does not support this
feature, either, so you cannot implement it on top of fgets.

If you need to deal with different line end conventions on
various systems, Python 2.3 offers a Universal Newline
Support (PEP 278).

For uses beyond that, I recommend to read the entire file,
then do .split on the resulting string. This is the common
solution to your problem, and it works quite well.
msg223994 - (view) Author: Akira Li (akira) * Date: 2014-07-25 20:21
Reincarnation: issue #1152248: Add support for reading records with 
arbitrary separators to the standard IO stack
History
Date User Action Args
2022-04-10 16:05:22adminsetgithub: 36685
2014-07-25 20:21:08akirasetnosy: + akira
messages: + msg223994
2002-06-02 08:04:43bescotocreate