[Python-Dev] New regex module for 3.2?

Georg Brandl g.brandl at gmx.net
Mon Jul 26 23:06:25 CEST 2010


Am 22.07.2010 12:53, schrieb Guido van Rossum:
> On Fri, Jul 16, 2010 at 6:08 PM, Georg Brandl <g.brandl at gmx.net> wrote:
>> Nevertheless, the authoritative reference for our regex engine is its
>> docs, i.e. http://docs.python.org/library/re.html -- and that states
>> clearly that inline flags apply to the whole regex.
>>
>>> I think with a new regex implementation, not all of this "historical"
>>> semantics must be copied, unless there are major real usecases, which
>>> would be affected by this.
>>
>> As I already said, I *have* seen this in real code.  As MRAB indicated,
>> this was the only silent change in semantics as compared to the old
>> regex engine.  If we replace re by regex, which I think is the only
>> way to get the new features in the stdlib, changing this one aspect is
>> a) not backwards compatible and b) in a subtle way that forces everyone
>> to review his/her regular expressions.  That's definitely not
>> acceptable.
> 
> I wonder if the solution could be a new flag that you have to specify
> if you want the flags to apply locally only. Let's say add 'L' to the
> flags. Then for existing code (not using 'L') the flags should apply
> globally, while someone wanting flags to apply to only part of a regex
> can add 'L' to the flags syntax.
> 
> Is that acceptable?

I guess it would be; however it remains to be proven that this scoping
is actually needed in addition to the (backwards compatible) grouped
scoping.

Georg

-- 
Thus spake the Lord: Thou shalt indent with four spaces. No more, no less.
Four shall be the number of spaces thou shalt indent, and the number of thy
indenting shall be four. Eight shalt thou not indent, nor either indent thou
two, excepting that thou then proceed to four. Tabs are right out.



More information about the Python-Dev mailing list