[Python-Dev] New regex module for 3.2?

Guido van Rossum guido at python.org
Thu Jul 22 12:53:12 CEST 2010


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?

-- 
--Guido van Rossum (python.org/~guido)


More information about the Python-Dev mailing list