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

Steven D'Aprano report at bugs.python.org
Sun Oct 7 04:49:53 EDT 2018


Steven D'Aprano <steve+python at pearwood.info> added the comment:

I don't like the idea of adding a second bool parameter to splitlines. Guido has a rough rule of thumb (which I agree with) of "no constant bool parameters". If people will typically call a function with some sort of "mode" parameter using a hard-coded bool, then we should usually prefer to split the two modes into distinct functions.

As an example, we have statistics.stdev and pstdev rather than stdev(data, population=False).

Obviously this is a guideline, not a hard rule, and there are exceptions. Such as str.splitlines :-)

In any case, I suggest a separate string method. Even though the name is slightly inaccurate, I suggest "ascii_splitlines" which I think is accurate enough to capture the spirit of what we intend (split on *only* \n \r and \r\n) and we can leave the details in the docs.

----------
nosy: +steven.daprano

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


More information about the Python-bugs-list mailing list