[Python-ideas] Experiment: Adding "re" to string objects.
Lie Ryan
lie.1296 at gmail.com
Tue Jul 21 13:55:57 CEST 2009
Steven D'Aprano wrote:
> On Tue, 21 Jul 2009 07:47:05 am Sean Reifschneider wrote:
>
>> if s.re.match(r'whatever(.*)'):
>> s.re.group(1)
>
> To me, the above is far less attractive than the standard idiom. That's
> an aesthetic judgement which you might disagree with, but I believe
> there's a far more critical flaw in the above idiom: it operates by
> side-effect in an unsafe way.
I agree with your concerns. Then how about restricting so
str.match/str.re.match would only return True or False? Basically,
str.match/str.re.match is only used to determine whether a string
matches a regular expression and not to extract information out of the
string.
More information about the Python-ideas
mailing list