[Python-ideas] Raw strings return compiled regexps

Neil Toronto ntoronto at cs.byu.edu
Fri Nov 9 23:51:26 CET 2007


It seems like every time somebody has issues with raw strings, the 
canonical answer is "don't use them for that, use the for regular 
expressions".

What if they just returned regular expression objects? As in

   r'<some long exp>'.match('<my string>')

That would guarantee they didn't get abused for anything else. It would 
break a lot of code, too. :)

Quick question, if someone has the time: is there any way to test 
equivalence of regular expressions? If we had intersection and an 
emptiness test (both of which are easy in the theoretical construct, but 
harder to do in practice), it'd be easy. I may be able to fake 
intersection using lookahead and such, but there's no emptiness test 
that I know of.

Thanks in advance,
Neil



More information about the Python-ideas mailing list