classification
Title: Add tuple/list sep to string split method
Type: Stage:
Components: Interpreter Core Versions:
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: rhettinger, tshepang
Priority: normal Keywords:

Created on 2011-02-09 19:46 by tshepang, last changed 2011-02-09 20:08 by rhettinger. This issue is now closed.

Messages (2)
msg128234 - (view) Author: Tshepang Lekhonkhobe (tshepang) * Date: 2011-02-09 19:46
I was hoping that I could use a list/tuple of separators for the split method:

    "abcde".split(["b", "d"])

vs.

    import re
    re.split("b|d", "abcde")

That's one extra LOC, and (worse still) forces me to learn regexp.

Does this suggested 'improvement' make sense?
msg128235 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2011-02-09 20:08
> Does this suggested 'improvement' make sense?

Sorry, it doesn't make sense for a number of reasons.

* First the str.split() is already too complex.  It took years to get the docs for it to be correct and informative (two different algorithms, etc).

* Second, it would overly complicate the implementation and preclude various kinds of string search optimizations (i.e. that is why fgrep, grep, and egrep are still separate).

* Third, at some point, when you need a regex, you just need to use a regex.  It would be a mistake to reinvent regex capabilities in string objects.
History
Date User Action Args
2011-02-09 20:08:28rhettingersetstatus: open -> closed

nosy: + rhettinger
messages: + msg128235

resolution: rejected
2011-02-09 20:02:24tshepangsetcomponents: + Interpreter Core, - Library (Lib)
2011-02-09 19:46:22tshepangcreate