General approach for a list of splitters, please can anyone write this with less code?
Initializing vars:
>>> splits = ['.', '-', ':', ','] >>> s='hola, que: tal. be'
Cutting:
>>> r = [ s ] >>> for p in splits: ... r = reduce(lambda x,y: x+y, map(lambda z: z.split(p), r ))
Results:
>>> r ['hola', ' que', ' tal', ' be']
source share