[issue2636] Adding a new regex module (compatible with re)

Ezio Melotti report at bugs.python.org
Fri Sep 2 05:38:13 CEST 2011


Ezio Melotti <ezio.melotti at gmail.com> added the comment:

Also note that some behaviors are not "old" or "compatible", but just different.  For example why inline flags should be the old (or new) behavior?  Or e.g. the behavior of version 2 but not 0 and 1?
Also what if I want zero-width splits but not nested sets and sets operations?  Or if I want inline flags but not zero-width splits?

A new set of "features" flags might be an alternative approach.  It will also make possible to add new features that are not backward compatible that can be turned on explicitly with their flag.

It would be fine for me if I had to turn on explicitly e.g. nested sets if/when I'll need to use them, and keep having the "normal" behavior otherwise.

OTOH there are three problems with these approach:
  1) it's not compatible with regex (I guess people will use the external module in Python <3.3 and the included one in 3.3+, probably expecting the same semantics).  This is also true with the OLD/COMPAT flag though;
  2) it might require other inline feature-flags;
  3) the new set of flags might be added to the other flags or be separate, so e.g. re.compile(pattern, flags=re.I|re.NESTEDSETS) or re.compile(pattern, flags=re.I, features=re.NESTEDSETS).  I'm not sure it's a good idea to add another arg though.

Matthew, is there a comprehensive list of all the bugfix/features that have a different behavior from re?
We should first check what changes are acceptable and what aren't, and depending on how many and what they are we can then decide what is the best approach (a catch-all flag or several flags to change the behavior, transition period + warning before setting it as default, etc.)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue2636>
_______________________________________


More information about the Python-bugs-list mailing list