Message381907
When I run the following code, I expected to get output result `['i am next line with [unk]']`, but instead I get the original list in `data`.
Code snippet
```py
import re
data = [
'= hello =',
'i am next line with <unk>',
]
pttn = re.compile(r'=.*=')
samples = filter(lambda sample: not pttn.match(sample), data)
pttn = re.compile(r'<unk>')
samples = map(lambda sample: pttn.sub('[unk]', sample), samples)
print(list(samples))
```
I suspect that is the cache provide by `re.compile` cause the problem.
The `sub` function in `map` is somehow begin link to the first `pttn`.
If I instead rename the second `pttn` to `pttn2`, then it work magically, but this is not expected. |
|
Date |
User |
Action |
Args |
2020-11-26 18:29:35 | ProFatXuanAll | set | recipients:
+ ProFatXuanAll, ezio.melotti, mrabarnett |
2020-11-26 18:29:35 | ProFatXuanAll | set | messageid: <1606415375.3.0.603801258306.issue42475@roundup.psfhosted.org> |
2020-11-26 18:29:35 | ProFatXuanAll | link | issue42475 messages |
2020-11-26 18:29:35 | ProFatXuanAll | create | |
|