Steven Bethard wrote: [snip] > And it appears to work: [snip] > But it seems somewhat inelegant. Can anyone see an easier/cleaner/more > Pythonic way[1] of writing this code? > > Thanks in advance, > > STeVe > > [1] Yes, I'm aware that these are subjective terms. I'm looking for > subjectively "better" solutions. ;)
Perhaps you should define "work" before you worry about """subjectively "better" solutions""". If "work" is meant to detect *all* possibilities of 'chunks' not having been derived from 'text' in the described manner, then it doesn't work -- all information about the positions of the whitespace is thrown away by your code. For example, text = 'foo bar', chunks = ['foobar'] -- http://mail.python.org/mailman/listinfo/python-list