Guido van Rossum added the comment:

The doc Ezio quotes for \number is describing the regex syntax, not the 
substitution string syntax. Unfortunately this syntax is documented somewhat 
less formally than the regex syntax.  Fortunately, it does mention explicitly 
that \g<0> substitutes the entire string, and that does work:

>>> re.sub(r'xxx', r'(\g<0>)', 'abcxxxdef')
'abc(xxx)def'
>>> 

For backward compatibility reasons I don't think we can change this, and I 
don't see a need either, given that \g<0> works.  Regex syntax in Python is 
what it is -- other languages can have only limited influence.  (We once 
started out with an approximation of what Perl offered at the time, knowing 
that we would eventually get out of sync with Perl, and we were okay with that.)

----------
resolution:  -> rejected
status: open -> closed

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue17426>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to