Stupid string.split question

Peter Hansen peter at engcorp.com
Wed Aug 6 16:11:18 EDT 2003


Andrew Dalke wrote:
> 
> Brian Kelley:
> > "ABCDEF".split("") shouldn't equal ["A", "B", "C", "D", "E", "F"]?
> 
> (which, btw, raises a ValueError.)
> 
> Hmm.  Perl does that, right?  I see your point about the symmetry,

It's only a token kind of symmetry, without much real value.  After
all, why shouldn't this be symmetrical, too, then? :

  ''.join(['abc', 'def', 'g', 'h']) --> 'abcdefgh'

  'abcdefgh'.split('') --> ['abc', 'def', 'g', 'h']

-avoiding-foolish-consistency-and-hobgoblins-ly y'rs,
 Peter




More information about the Python-list mailing list