split() and string.whitespace
bearophileHUGS at lycos.com
bearophileHUGS at lycos.com
Tue Nov 4 15:00:06 EST 2008
MRAB:
> It's interesting, if you think about it, that here we have someone who
> wants to split on a set of characters but 'split' splits on a string,
> and others sometimes want to strip off a string but 'strip' strips on
> a set of characters (passed as a string).
That can be seen as a little inconsistency in the language. But with
some practice you learn it.
> You could imagine that if
> Python had had (character) sets from the start then 'split' and
> 'strip' could have accepted a string or a set depending on whether you
> wanted to split on or stripping off a string or a set.
Too bad you haven't suggested this when they were designing Python
3 :-)
This may be suggested for Python 3.1.
Bye,
bearophile
More information about the Python-list
mailing list