Message155484
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/sre_parse.py", 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/re.py", line 286, in filter
return sre_parse.expand_template(template, match)
File "/usr/local/lib/python3.2/sre_parse.py", 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:18 | py.user | set | recipients:
+ py.user, ezio.melotti, mrabarnett |
2012-03-12 21:37:18 | py.user | set | messageid: <1331588238.77.0.980984426494.issue14260@psf.upfronthosting.co.za> |
2012-03-12 21:37:18 | py.user | link | issue14260 messages |
2012-03-12 21:37:17 | py.user | create | |
|