def tsplit(string, delimiters):
"""Behaves str.split but supports multiple delimiters."""
delimiters = tuple(delimiters)
stack = [string,]
for delimiter in delimiters:
for i, substring in enumerate(stack):
substack = substring.split(delimiter)
stack.pop(i)
for j, _substring in enumerate(substack):
stack.insert(i+j, _substring)
return stack
Diff to Previous Revision
--- revision 4 2011-03-20 20:27:54
+++ revision 5 2011-03-20 20:33:13
@@ -9,7 +9,6 @@
substack = substring.split(delimiter)
stack.pop(i)
for j, _substring in enumerate(substack):
- if len(_substring):
- stack.insert(i+j, _substring)
+ stack.insert(i+j, _substring)
return stack