-inf
That breaks existing code in two different ways which I don't think makes it easy.
it does NOT collapse adjacent characters:
>>> "a&&b".split("&")
['a', '', 'b']
the separator it splits on is a string, not a character:
>>> "a<b><c>d".split("><")
['a<b', 'c>d']
--- Bruce
Without getting into regular expressions, it's easier to just allow adjacent char matches to act as one match so the following is true.
Bruce Leban wrote:
I think string.split(list) probably won't do what people expect either. Here's what I would expect it to do:
>>> '1 (123) 456-7890'.split([' ', '(', ')', '-'])
['1', '', '123', '', '456', '7890']
but what you probably want is:
>>>re.split(r'[ ()-]*', '1 (123) 456-7890')
['1', '123', '456', '7890']
using allows you to do that and avoids ambiguity about what it does.
--- Bruce
longstring.splitchars(string.whitespace) = longstring.split()
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
http://mail.python.org/mailman/listinfo/python-ideas