Author py.user
Recipients ezio.melotti, mrabarnett, py.user
Date 2012-03-12.21:37:17
SpamBayes Score 1.32785e-06
Marked as misclassified No
Message-id <>
Matthew Barnett wrote:
> The re module creates the dict purely for the benefit of the user

this dict affects on regex.sub()

>>> import re
>>> p = re.compile(r'abc(?P<n>def)')
>>> p.groupindex
{'n': 1}
>>> p.groupindex['n'] = 2
>>> p.sub(r'\g<n>', 'abcdef')
Traceback (most recent call last):
  File "/usr/local/lib/python3.2/", line 811, in expand_template
    literals[index] = s = g(group)
IndexError: no such group

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.2/", line 286, in filter
    return sre_parse.expand_template(template, match)
  File "/usr/local/lib/python3.2/", line 815, in expand_template
    raise error("invalid group reference")
sre_constants.error: invalid group reference
Date User Action Args
2012-03-12 21:37:18py.usersetrecipients: + py.user, ezio.melotti, mrabarnett
2012-03-12 21:37:18py.usersetmessageid: <>
2012-03-12 21:37:18py.userlinkissue14260 messages
2012-03-12 21:37:17py.usercreate