Re: str.split() with empty separator

2009-09-17 Thread David C Ullrich
On Tue, 15 Sep 2009 14:31:26 +0200, Ulrich Eckhardt wrote: > Hi! > > "'abc'.split('')" gives me a "ValueError: empty separator". However, > "''.join(['a', 'b', 'c'])" gives me "'abc'". > > Why this asymmetry? The docs say "If sep is given, consecutive delimiters are not grouped together and a

Re: str.split() with empty separator

2009-09-16 Thread Hendrik van Rooyen
On Tuesday 15 September 2009 14:50:11 Xavier Ho wrote: > On Tue, Sep 15, 2009 at 10:31 PM, Ulrich Eckhardt > > wrote: > > "'abc'.split('')" gives me a "ValueError: empty separator". > > However, "''.join(['a', 'b', 'c'])" gives me "'abc'". > > > > Why this asymmetry? I was under the impression that

Re: str.split() with empty separator

2009-09-15 Thread MRAB
Vlastimil Brom wrote: 2009/9/15 Ulrich Eckhardt : Hi! "'abc'.split('')" gives me a "ValueError: empty separator". However, "''.join(['a', 'b', 'c'])" gives me "'abc'". Why this asymmetry? I was under the impression that the two would be complementary. Uli maybe it isn't quite obvious, what

Re: str.split() with empty separator

2009-09-15 Thread Vlastimil Brom
2009/9/15 Ulrich Eckhardt : > Hi! > > "'abc'.split('')" gives me a "ValueError: empty separator". > However, "''.join(['a', 'b', 'c'])" gives me "'abc'". > > Why this asymmetry? I was under the impression that the two would be > complementary. > > Uli > maybe it isn't quite obvious, what the behav

Re: str.split() with empty separator

2009-09-15 Thread Dave Angel
Ulrich Eckhardt wrote: Hi! "'abc'.split('')" gives me a "ValueError: empty separator". However, "''.join(['a', 'b', 'c'])" gives me "'abc'". Why this asymmetry? I was under the impression that the two would be complementary. Uli I think the problem is that join() is lossy; if you try "".

Re: str.split() with empty separator

2009-09-15 Thread Xavier Ho
On Tue, Sep 15, 2009 at 10:31 PM, Ulrich Eckhardt wrote: > "'abc'.split('')" gives me a "ValueError: empty separator". > However, "''.join(['a', 'b', 'c'])" gives me "'abc'". > > Why this asymmetry? I was under the impression that the two would be > complementary. > I'm not sure about asymmetry,

str.split() with empty separator

2009-09-15 Thread Ulrich Eckhardt
Hi! "'abc'.split('')" gives me a "ValueError: empty separator". However, "''.join(['a', 'b', 'c'])" gives me "'abc'". Why this asymmetry? I was under the impression that the two would be complementary. Uli -- Sator Laser GmbH Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932 -