new string method in 2.5 (partition)

Duncan Booth duncan.booth at invalid.invalid
Tue Sep 19 17:24:08 EDT 2006


"George Sakkis" <george.sakkis at gmail.com> wrote:

> Bruno Desthuilliers wrote:
> 
>> I must definitively be dumb, but so far I fail to see how it's better
>> than split and rsplit:
> 
> I fail to see it too. What's the point of returning the separator since
> the caller passes it anyway* ?
> 
The separator is only returned if it was found otherwise you get back an 
empty string. Concatenating the elements of the tuple that is returned 
always gives you the original string.

It is quite similar to using split(sep,1), but reduces the amount of 
special case handling for cases where the separator isn't found.




More information about the Python-list mailing list