new string method in 2.5 (partition)

Thomas Heller theller at python.net
Tue Sep 19 15:38:40 EDT 2006


John Salerno schrieb:
> Bruno Desthuilliers wrote:
> 
>> Err... is it me being dumb, or is it a perfect use case for str.split ?
> 
> Hmm, I suppose you could get nearly the same functionality as using 
> split(':', 1), but with partition you also get the separator returned as 
> well.

Well, x.split(":", 1) returns a list of one or two elements, depending on x,
while x.partition(":") always returns a three-tuple.

Thomas




More information about the Python-list mailing list