a splitting headache

Paul Rubin http
Fri Oct 16 03:49:28 CEST 2009


Mensanator <mensanator at aol.com> writes:
> And the re module doesn't help.
> 
> >>> f = '  1 2  3   4    '
> >>> re.split(' ',f)
> ['', '', '1', '2', '', '3', '', '', '4', '', '', '', '']

filter(bool, re.split(' ', f))

You might also like:

    from itertools import groupby
    c = '0010000110'
    print list(list(xs) for k,xs in groupby(c))



More information about the Python-list mailing list