str.split() with empty separator

Dave Angel davea at
Tue Sep 15 15:35:58 CEST 2009

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  "".join(['a', 
'bcd', 'e'])   then there's no way to reconstruct the original list with 
split().  Now that can be true even with actual separators,  but perhaps 
this was the reasoning.

Anyway, if you want to turn a string into a list of single-character 
strings, then use


More information about the Python-list mailing list