You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: