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.

Author abarry
Recipients abarry, barry, mrabarnett, rhettinger, serhiy.storchaka
Date 2016-12-11.23:58:37
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1481500717.29.0.664650266744.issue28937@psf.upfronthosting.co.za>
In-reply-to
Content
Matthew: Yes, that's exactly the way I was going about it.

Thank you Raymond for your comments (and your informative answer on that SO question).

I think that part of the problem is that no delimiter (or None) behaves differently than with a delimiter. If we wanted proper consistency, we would have needed to make passing None (or nothing) the same as passing whitespace, but alas, we have to work with what we have.

As you said, API complexity is a concern that needs to be addressed. I think that the most important part is how it's documented, and, if phrased correctly (which is non-trivial), could actually simplify the explanation.

Consider this draft:

***

The value of the `prune` keyword argument determines whether or not consecutive delimiters should be grouped together. If `prune` is not given or None, it defaults to True if sep is None or not given, and False otherwise.

If `prune` is True, consecutive delimiters (all whitespace if None or not given) are regarded as a single separator, and the result will not contain any empty string. The resulting list may be empty.

Otherwise, if `prune` is False, consecutive delimiters are not grouped together, and the result may contain one or more empty string. The resulting list will never be empty.

***

I may be oversimplifying this, but it seems to me that this might help some people by hopefully streamlining the explanation.

This still doesn't solve the issue where a user can't say "split on a space or a tab, but not newlines", which IMO is lacking in the design, but that may be for another issue ;)

I've wrapped up a basic patch which probably doesn't work at all; I'll put it up when it's at least partly working for everyone to look at.
History
Date User Action Args
2016-12-11 23:58:37abarrysetrecipients: + abarry, barry, rhettinger, mrabarnett, serhiy.storchaka
2016-12-11 23:58:37abarrysetmessageid: <1481500717.29.0.664650266744.issue28937@psf.upfronthosting.co.za>
2016-12-11 23:58:37abarrylinkissue28937 messages
2016-12-11 23:58:37abarrycreate