Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add separator argument to readline() #36685

Closed
bescoto mannequin opened this issue Jun 2, 2002 · 3 comments
Closed

Add separator argument to readline() #36685

bescoto mannequin opened this issue Jun 2, 2002 · 3 comments
Labels
stdlib Python modules in the Lib dir

Comments

@bescoto
Copy link
Mannequin

bescoto mannequin commented Jun 2, 2002

BPO 563491
Nosy @loewis, @4kir4

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2014-07-25.20:21:08.234>
created_at = <Date 2002-06-02.08:04:43.000>
labels = ['library']
title = 'Add separator argument to readline()'
updated_at = <Date 2014-07-25.20:21:08.234>
user = 'https://bugs.python.org/bescoto'

bugs.python.org fields:

activity = <Date 2014-07-25.20:21:08.234>
actor = 'akira'
assignee = 'none'
closed = True
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2002-06-02.08:04:43.000>
creator = 'bescoto'
dependencies = []
files = []
hgrepos = []
issue_num = 563491
keywords = []
message_count = 3.0
messages = ['11016', '11017', '223994']
nosy_count = 3.0
nosy_names = ['loewis', 'bescoto', 'akira']
pr_nums = []
priority = 'normal'
resolution = 'rejected'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue563491'
versions = []

@bescoto
Copy link
Mannequin Author

bescoto mannequin commented Jun 2, 2002

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.

@bescoto bescoto mannequin closed this as completed Jun 2, 2002
@bescoto bescoto mannequin added the stdlib Python modules in the Lib dir label Jun 2, 2002
@bescoto bescoto mannequin closed this as completed Jun 2, 2002
@bescoto bescoto mannequin added the stdlib Python modules in the Lib dir label Jun 2, 2002
@loewis
Copy link
Mannequin

loewis mannequin commented Jun 2, 2002

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.

@4kir4
Copy link
Mannequin

4kir4 mannequin commented Jul 25, 2014

Reincarnation: issue bpo-1152248: Add support for reading records with
arbitrary separators to the standard IO stack

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir
Projects
None yet
Development

No branches or pull requests

0 participants