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 are deemed to delimit empty strings (for example, '1,,2'.split(',') returns ['1', '', '2']). " Now suppose sep = ''. That means split() should return an infinitely long list of empty strings! Because if sep = '' then the string 'hello' starts with an empty string followed by sep followed by an empty string followed by sep followed by an empty string followed by sep... that's all before we get to the 'h'. > I was under the impression that the two would be > complementary. > > Uli -- http://mail.python.org/mailman/listinfo/python-list