aligning text with space-normalized text
Steven Bethard
steven.bethard at gmail.com
Fri Jul 1 00:52:42 EDT 2005
John Machin wrote:
> Steven Bethard wrote:
>
>> John Machin wrote:
>>
>>> For example, text = 'foo bar', chunks = ['foobar']
>>
>> This doesn't match the (admittedly vague) spec
>
> That is *exactly* my point -- it is not valid input, and you are not
> reporting all cases of invalid input; you have an exception where the
> non-spaces are impossible, but no exception where whitespaces are
> impossible.
Well, the input should never look like the above. But if for some
reason it did, I wouldn't want the error; I'd want the indices. So:
text = 'foo bar'
chunks = ['foobar']
should produce:
[(0, 7)]
not an exception.
STeVe
More information about the Python-list
mailing list