string.split

Gustavo Niemeyer niemeyer at conectiva.com
Wed Sep 5 18:06:27 CEST 2001


Hi there!

> > set a literal string that is the seperator. How do I split on any or all
> > occurrences of (for example) whitespace and a comma, without using
> regexes.
> > I mean string.split() must be able to do it anyway to achieve the default
> > behaviour.
> 
> Nope -- look at objects/stringobject.c: string_split specialcases out
> a call to split_whitespace when the splitter argument is missing or
> None, and split_whitespace uses C's isspace to check for splitting.
> 
> I think it's a reasonable feature-request to wish for split to be
> able to split on any one of several strings (e.g., make it callable
> with several string arguments, or maybe with an argument that's a
> sequence of strings), but feature-request it is -- it would need
> additional code in stringobject.c.  So, you're advised to submit it
> as a feature request to sourceforge.

Don't waste your time. I thought this would be a resonable feature and
implemented a splitlist() method for strings, doing exactly this. After
some discussions, it has been decided by the python crew that re.split
was enough and adding a new functionality like this would "bloat" the
code.

If you want more information about this, have a look at python's patches
at sourceforge. If you can't find it and want me to send the patch for
research purposes, let me know.

-- 
Gustavo Niemeyer

[ 2AAC 7928 0FBF 0299 5EB5  60E2 2253 B29A 6664 3A0C ]




More information about the Python-list mailing list