Behavior of re.split on empty strings is unexpected

rantingrick rantingrick at gmail.com
Mon Aug 2 23:42:14 EDT 2010


On Aug 2, 7:53 pm, samwyse <samw... at gmail.com> wrote:

> It's the same results; however many people don't like these results
> because they feel that whitespace occupies a privileged role.  People
> generally agree that a string of consecutive commas means missing
> values, but a string of consecutive spaces just means someone held the
> space-bar down too long.  To accommodate this viewpoint, the string
> split is special-cased to behave differently when None is passed as a
> separator.  First, it splits on any number of whitespace characters,
> like this:

Well we could have created another method like "splitstrip()". However
then folks would complain that they must remember two methods that are
almost identical. Uggh, you just can't win. There is always the
naysayers no matter what you do!

PS: Great post by the way. Highly informative for the pynoobs.




More information about the Python-list mailing list