[Python-Dev] Proof of the pudding: str.partition()

Reinhold Birkenfeld reinhold-birkenfeld-nospam at wolke7.net
Wed Aug 31 22:49:23 CEST 2005


Bill Janssen wrote:
>> >    (*) Regular Expressions
>> 
>> This can be orthogonally added to the 're' module, and definitely should 
>> not be part of the string method.
> 
> Sounds right to me, and it *should* be orthogonally added to the 're'
> module coincidentally simultaneously with the change to the string
> object :-).
> 
> I have to say, it would be nice if
> 
>        "foo bar".partition(re.compile('\s'))
> 
> would work.  That is, if the argument is an re pattern object instead
> of a string, it would be nice if it were understood appropriately,
> just for symmetry's sake.  But it's hardly necessary.

And it's horrible, for none of the other string methods accept a RE.

In Python, RE functionality is in the re module and nowhere else, and this
is a Good Thing. There are languages which give REs too much weight by philosophy
(hint, hint), but Python isn't one of them. Interestingly, Python programmers
suffer less from the "help me, my RE doesn't work" problem.

Reinhold

-- 
Mail address is perfectly valid!



More information about the Python-Dev mailing list