[docs] [issue22232] str.splitlines splitting on non-\r\n characters

Neil Schemenauer report at bugs.python.org
Fri Oct 5 10:04:22 EDT 2018


Neil Schemenauer <nas-python at arctrix.com> added the comment:

I've created a topic on this inside the "Ideas" area of discuss.python.org.  Sorry if that wasn't appropriate, not sure if I should have keep the discussion here.

Inada Naoki suggests creating a new method str.iterlines{[keepends]).  Given that people are -1 on changing str.splitlines, I think that's a good solution.  A new method is better yet if it would only split on '\n', that way fp.read().iterlines() matches fp.readlines().  It is what people seem to expect and is the most handy behaviour.  So, str and bytes would both get the new method and they would both split on only '\n'.

If we do that, I think nearly every use of splitlines() should get changed to iterlines().

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue22232>
_______________________________________


More information about the docs mailing list