Behaviour of str.split

runes rune.strand at gmail.com
Mon Apr 18 12:01:26 EDT 2005


The behaviour of "".split("*") is not that strange as the splitpoint
always disappear. The re.split() have a nice option to keep the
splitpoint which the str.split should have, I think.

One expectation I keep fighting within myself is that I expect

"mystring".split('') to return  ['m', 'y', 's', 't', 'r', 'i', 'n',
'g']. But I guess it's in line with "There should be one-- and
preferably only one --obvious way to do it." that it's not so.




More information about the Python-list mailing list